import sys

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N, K = rl()
max = (N-1) * (N-2) // 2
if K > max:
    print(-1)
    exit()
edges = []
for i in range(2, N+1):
    edges.append((1, i))
count = max - K
for i in range(2, N):
    if count == 0:
        break
    for j in range(i+1, N+1):
        if count == 0:
            break
        edges.append((i, j))
        count -= 1
print(len(edges))
for x in edges:
    print(*x)
 import sys sys stdin = sys.stdin stdin sys.stdin sys stdin sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 ri = lambda: int(rs()) ri lambda: int(rs()) int(rs()) int rs() rs rl = lambda: list(map(int, stdin.readline().split())) rl lambda: list(map(int, stdin.readline().split())) list(map(int, stdin.readline().split())) list map(int, stdin.readline().split()) map int stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split rs = lambda: stdin.readline().rstrip() rs lambda: stdin.readline().rstrip() stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip N, K = rl() N rl() rl K max = (N-1) * (N-2) // 2 max (N-1) * (N-2) // 2 (N-1) * (N-2) N-1 N 1 N-2 N 2 2 if K > max:
    print(-1)
    exit() K > max K max print(-1) print -1 exit() exit 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 count = max - K count max - K max K for i in range(2, N):
    if count == 0:
        break
    for j in range(i+1, N+1):
        if count == 0:
            break
        edges.append((i, j))
        count -= 1 i range(2, N) range 2 N if count == 0:
        break
     count == 0 count 0 break for j in range(i+1, N+1):
        if count == 0:
            break
        edges.append((i, j))
        count -= 1 j range(i+1, N+1) range i+1 i 1 N+1 N 1 if count == 0:
            break
         count == 0 count 0 break edges.append((i, j)) edges.append edges append (i, j) i j count -= 1 count 1 print(len(edges)) print len(edges) len edges for x in edges:
    print(*x) x edges print(*x) print *x x edges = [] [] edges max = (N-1) * (N-2) // 2 (N-1) * (N-2) // 2 max K = rl() rl() K rl = lambda: list(map(int, stdin.readline().split())) lambda: list(map(int, stdin.readline().split())) rl count = max - K max - K count stdin = sys.stdin sys.stdin stdin rs = lambda: stdin.readline().rstrip() lambda: stdin.readline().rstrip() rs N, K = rl() rl() N ri = lambda: int(rs()) lambda: int(rs()) ri count -= 1 1 count
import sys

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N, K = rl()
max = (N-1) * (N-2) // 2
if K > max:
    print(-1)
    exit()
edges = []
for i in range(2, N+1):
    edges.append((1, i))
count = max - K
for i in range(2, N):
    if count == 0:
        break
    for j in range(i+1, N+1):
        if count == 0:
            break
        edges.append((i, j))
        count -= 1
print(len(edges))
for x in edges:
    print(*x)

