N, K = map(int, input().split())

if K>(N-1)*(N-2)//2:
    print(-1)
    exit()
    
edges = []

for i in range(1, N):
    edges.append((i, N))
    
cnt = 0

for i in range(1, N):
    for j in range(i+1, N):
        if cnt==(N-1)*(N-2)//2-K:
            break
        
        edges.append((i, j))
        cnt += 1

print(len(edges))

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

if K>(N-1)*(N-2)//2:
    print(-1)
    exit()
    
edges = []

for i in range(1, N):
    edges.append((i, N))
    
cnt = 0

for i in range(1, N):
    for j in range(i+1, N):
        if cnt==(N-1)*(N-2)//2-K:
            break
        
        edges.append((i, j))
        cnt += 1

print(len(edges))

for ui, vi in edges:
    print(ui, vi)