from collections import deque
n, k = map(int, input().split())
edges = deque()

if k > (n-1)*(n-2)/2:
    print(-1)
    exit()

for i in range(1, n):
    for j in range(i+1, n+1):
        edges.append((i, j))
m = int((n-1) + (n-1)*(n-2)//2 - k)
print(m)
for i in range(m):
    edge = edges.popleft()
    print(*edge) from collections import deque n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k edges = deque() edges deque() deque 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 for i in range(1, n):
    for j in range(i+1, n+1):
        edges.append((i, j)) i range(1, n) range 1 n for j in range(i+1, n+1):
        edges.append((i, j)) j range(i+1, n+1) range i+1 i 1 n+1 n 1 edges.append((i, j)) edges.append edges append (i, j) i j m = int((n-1) + (n-1)*(n-2)//2 - k) m int((n-1) + (n-1)*(n-2)//2 - k) int (n-1) + (n-1)*(n-2)//2 - k (n-1) + (n-1)*(n-2)//2 n-1 n 1 (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 k print(m) print m for i in range(m):
    edge = edges.popleft()
    print(*edge) i range(m) range m edge = edges.popleft() edge edges.popleft() edges.popleft edges popleft print(*edge) print *edge edge edges = deque() deque() edges edge = edges.popleft() edges.popleft() edge n, k = map(int, input().split()) map(int, input().split()) n k = map(int, input().split()) map(int, input().split()) k m = int((n-1) + (n-1)*(n-2)//2 - k) int((n-1) + (n-1)*(n-2)//2 - k) m
from collections import deque
n, k = map(int, input().split())
edges = deque()

if k > (n-1)*(n-2)/2:
    print(-1)
    exit()

for i in range(1, n):
    for j in range(i+1, n+1):
        edges.append((i, j))
m = int((n-1) + (n-1)*(n-2)//2 - k)
print(m)
for i in range(m):
    edge = edges.popleft()
    print(*edge)