n,k = map(int, input().split())
m = (n-1)*(n-2)//2
if k > m:
    print(-1)
    exit()
r = m-k

edge = [[] for i in range(n)]
edge[0] = list(range(1, n))
for i in range(1, n):
    for j in range(i+1, n):
        if r == 0:
            break
        edge[i].append(j)
        r -= 1

m = sum(len(i) for i in edge)
print(m)
for i in range(n):
    for j in edge[i]:
        print(i+1, j+1) n,k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k m = (n-1)*(n-2)//2 m (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 if k > m:
    print(-1)
    exit() k > m k m print(-1) print -1 exit() exit r = m-k r m-k m k [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] edge = [[] for i in range(n)] edge [[] for i in range(n)] edge[0] = list(range(1, n)) edge[0] edge 0 list(range(1, n)) list range(1, n) range 1 n for i in range(1, n):
    for j in range(i+1, n):
        if r == 0:
            break
        edge[i].append(j)
        r -= 1 i range(1, n) range 1 n for j in range(i+1, n):
        if r == 0:
            break
        edge[i].append(j)
        r -= 1 j range(i+1, n) range i+1 i 1 n if r == 0:
            break
         r == 0 r 0 break edge[i].append(j) [i].append [i] edge i append j r -= 1 r 1 m = sum(len(i) for i in edge) m sum(len(i) for i in edge) sum len(i) len i print(m) print m for i in range(n):
    for j in edge[i]:
        print(i+1, j+1) i range(n) range n for j in edge[i]:
        print(i+1, j+1) j edge[i] edge i print(i+1, j+1) print i+1 i 1 j+1 j 1 m = (n-1)*(n-2)//2 (n-1)*(n-2)//2 m r -= 1 1 r r = m-k m-k r n,k = map(int, input().split()) map(int, input().split()) n k = map(int, input().split()) map(int, input().split()) k m = sum(len(i) for i in edge) sum(len(i) for i in edge) m edge = [[] for i in range(n)] [[] for i in range(n)] edge
n,k = map(int, input().split())
m = (n-1)*(n-2)//2
if k > m:
    print(-1)
    exit()
r = m-k

edge = [[] for i in range(n)]
edge[0] = list(range(1, n))
for i in range(1, n):
    for j in range(i+1, n):
        if r == 0:
            break
        edge[i].append(j)
        r -= 1

m = sum(len(i) for i in edge)
print(m)
for i in range(n):
    for j in edge[i]:
        print(i+1, j+1)