n,k = map(int,input().split())

if k > (n-1) * (n-2) // 2:
    print(-1)
else:
    print((n-1) * n // 2 - k)
    count = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            print(i,j)
            count += 1
            if count == (n-1) * n // 2 - k:
                exit() 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:
    print((n-1) * n // 2 - k)
    count = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            print(i,j)
            count += 1
            if count == (n-1) * n // 2 - k:
                exit() 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 print((n-1) * n // 2 - k) print (n-1) * n // 2 - k (n-1) * n // 2 (n-1) * n n-1 n 1 n 2 k count = 0 count 0 for i in range(1,n+1):
        for j in range(i+1,n+1):
            print(i,j)
            count += 1
            if count == (n-1) * n // 2 - k:
                exit() i range(1,n+1) range 1 n+1 n 1 for j in range(i+1,n+1):
            print(i,j)
            count += 1
            if count == (n-1) * n // 2 - k:
                exit() j range(i+1,n+1) range i+1 i 1 n+1 n 1 print(i,j) print i j count += 1 count 1 if count == (n-1) * n // 2 - k:
                exit() count == (n-1) * n // 2 - k count (n-1) * n // 2 - k (n-1) * n // 2 (n-1) * n n-1 n 1 n 2 k exit() exit count = 0 0 count n,k = map(int,input().split()) map(int,input().split()) n k = map(int,input().split()) map(int,input().split()) k count += 1 1 count
n,k = map(int,input().split())

if k > (n-1) * (n-2) // 2:
    print(-1)
else:
    print((n-1) * n // 2 - k)
    count = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            print(i,j)
            count += 1
            if count == (n-1) * n // 2 - k:
                exit()
