import itertools

n, k = map(int, input().split())
if k > (n - 1) * (n - 2) // 2:
    print(-1)
else:
    tmp = (n - 1) * (n - 2) // 2
    tmp -= k
    print(n - 1 + tmp)
    for i in range(1, n):
        print(i, n)
    if tmp == 0:
        exit()
    for lst in itertools.combinations(range(1, n), 2):
        print(lst[0], lst[1])
        tmp -= 1
        if tmp == 0:
            break import itertools itertools n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k if k > (n - 1) * (n - 2) // 2:
    print(-1)
else:
    tmp = (n - 1) * (n - 2) // 2
    tmp -= k
    print(n - 1 + tmp)
    for i in range(1, n):
        print(i, n)
    if tmp == 0:
        exit()
    for lst in itertools.combinations(range(1, n), 2):
        print(lst[0], lst[1])
        tmp -= 1
        if tmp == 0:
            break k > (n - 1) * (n - 2) // 2 k (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 print(-1) print -1 tmp = (n - 1) * (n - 2) // 2 tmp (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 tmp -= k tmp k print(n - 1 + tmp) print n - 1 + tmp n - 1 n 1 tmp for i in range(1, n):
        print(i, n)
     i range(1, n) range 1 n print(i, n) print i n if tmp == 0:
        exit()
     tmp == 0 tmp 0 exit() exit for lst in itertools.combinations(range(1, n), 2):
        print(lst[0], lst[1])
        tmp -= 1
        if tmp == 0:
            break lst itertools.combinations(range(1, n), 2) itertools.combinations itertools combinations range(1, n) range 1 n 2 print(lst[0], lst[1]) print lst[0] lst 0 lst[1] lst 1 tmp -= 1 tmp 1 if tmp == 0:
            break tmp == 0 tmp 0 break tmp = (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) // 2 tmp n, k = map(int, input().split()) map(int, input().split()) n tmp -= 1 1 tmp tmp -= k k tmp k = map(int, input().split()) map(int, input().split()) k
import itertools

n, k = map(int, input().split())
if k > (n - 1) * (n - 2) // 2:
    print(-1)
else:
    tmp = (n - 1) * (n - 2) // 2
    tmp -= k
    print(n - 1 + tmp)
    for i in range(1, n):
        print(i, n)
    if tmp == 0:
        exit()
    for lst in itertools.combinations(range(1, n), 2):
        print(lst[0], lst[1])
        tmp -= 1
        if tmp == 0:
            break