N, K = map(int,input().split())
if K > (N-1)*(N-2)//2:
    print(-1)
    exit()
M = N-1
cnt = (N-1)*(N-2)//2
edges = []
for i in range(2, N+1):
    edges.append((1, i))
for i in range(2, N+1):
    for j in range(i+1, N+1):
        if cnt == K:
            break
        edges.append((i, j))
        cnt -= 1
        M += 1
    if cnt == K:
        break
print(M)
for u, v in edges:
    print(u, v) 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)
    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 exit() exit M = N-1 M N-1 N 1 cnt = (N-1)*(N-2)//2 cnt (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 edges = [] edges [] for i in range(2, N+1):
    edges.append((1, i)) i range(2, N+1) range 2 N+1 N 1 edges.append((1, i)) edges.append edges append (1, i) 1 i for i in range(2, N+1):
    for j in range(i+1, N+1):
        if cnt == K:
            break
        edges.append((i, j))
        cnt -= 1
        M += 1
    if cnt == K:
        break i range(2, N+1) range 2 N+1 N 1 for j in range(i+1, N+1):
        if cnt == K:
            break
        edges.append((i, j))
        cnt -= 1
        M += 1
     j range(i+1, N+1) range i+1 i 1 N+1 N 1 if cnt == K:
            break
         cnt == K cnt K break edges.append((i, j)) edges.append edges append (i, j) i j cnt -= 1 cnt 1 M += 1 M 1 if cnt == K:
        break cnt == K cnt K break print(M) print M for u, v in edges:
    print(u, v) u v edges print(u, v) print u v cnt -= 1 1 cnt K = map(int,input().split()) map(int,input().split()) K edges = [] [] edges M = N-1 N-1 M cnt = (N-1)*(N-2)//2 (N-1)*(N-2)//2 cnt N, K = map(int,input().split()) map(int,input().split()) N M += 1 1 M
N, K = map(int,input().split())
if K > (N-1)*(N-2)//2:
    print(-1)
    exit()
M = N-1
cnt = (N-1)*(N-2)//2
edges = []
for i in range(2, N+1):
    edges.append((1, i))
for i in range(2, N+1):
    for j in range(i+1, N+1):
        if cnt == K:
            break
        edges.append((i, j))
        cnt -= 1
        M += 1
    if cnt == K:
        break
print(M)
for u, v in edges:
    print(u, v)
