import  sys
from itertools import combinations
n, k = [int(i) for i in sys.stdin.readline().split()]
if (n - 1) * (n - 2) // 2 < k:
    print(-1)
else:
    print(n - 1 + (n - 1) * (n - 2) // 2 - k)
    for i in range(2,n+1):
        print(1, i)
    cnt = 0
    for combi in combinations(range(2,n+1), 2):
        if (n - 1) * (n - 2) // 2 - k == cnt:
            break
        print(combi[0], combi[1])
        cnt += 1 import  sys sys from itertools import combinations int(i) for i in sys.stdin.readline().split() for i in sys.stdin.readline().split() i sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for i in sys.stdin.readline().split() int(i) int i n, k = [int(i) for i in sys.stdin.readline().split()] n [int(i) for i in sys.stdin.readline().split()] k if (n - 1) * (n - 2) // 2 < k:
    print(-1)
else:
    print(n - 1 + (n - 1) * (n - 2) // 2 - k)
    for i in range(2,n+1):
        print(1, i)
    cnt = 0
    for combi in combinations(range(2,n+1), 2):
        if (n - 1) * (n - 2) // 2 - k == cnt:
            break
        print(combi[0], combi[1])
        cnt += 1 (n - 1) * (n - 2) // 2 < k (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 k print(-1) print -1 print(n - 1 + (n - 1) * (n - 2) // 2 - k) print n - 1 + (n - 1) * (n - 2) // 2 - k n - 1 + (n - 1) * (n - 2) // 2 n - 1 n 1 (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 k for i in range(2,n+1):
        print(1, i)
     i range(2,n+1) range 2 n+1 n 1 print(1, i) print 1 i cnt = 0 cnt 0 for combi in combinations(range(2,n+1), 2):
        if (n - 1) * (n - 2) // 2 - k == cnt:
            break
        print(combi[0], combi[1])
        cnt += 1 combi combinations(range(2,n+1), 2) combinations range(2,n+1) range 2 n+1 n 1 2 if (n - 1) * (n - 2) // 2 - k == cnt:
            break
         (n - 1) * (n - 2) // 2 - k == cnt (n - 1) * (n - 2) // 2 - k (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 k cnt break print(combi[0], combi[1]) print combi[0] combi 0 combi[1] combi 1 cnt += 1 cnt 1 cnt = 0 0 cnt n, k = [int(i) for i in sys.stdin.readline().split()] [int(i) for i in sys.stdin.readline().split()] n k = [int(i) for i in sys.stdin.readline().split()] [int(i) for i in sys.stdin.readline().split()] k cnt += 1 1 cnt
import  sys
from itertools import combinations
n, k = [int(i) for i in sys.stdin.readline().split()]
if (n - 1) * (n - 2) // 2 < k:
    print(-1)
else:
    print(n - 1 + (n - 1) * (n - 2) // 2 - k)
    for i in range(2,n+1):
        print(1, i)
    cnt = 0
    for combi in combinations(range(2,n+1), 2):
        if (n - 1) * (n - 2) // 2 - k == cnt:
            break
        print(combi[0], combi[1])
        cnt += 1