import sys
from itertools import combinations

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
limit = (N-1) * (N-2) // 2
if K > limit:
    print(-1); exit()

A = [(1, x) for x in range(2, N+1)]
# limit - K だけ辺を引く
for i, (x, y) in zip(range(limit-K), combinations(range(2, N+1), 2)):
    A.append((x, y))

print(len(A))
for a in A:
    print(*a) import sys sys from itertools import combinations sr = lambda: sys.stdin.readline().rstrip() sr lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip ir = lambda: int(sr()) ir lambda: int(sr()) int(sr()) int sr() sr lr = lambda: list(map(int, sr().split())) lr lambda: list(map(int, sr().split())) list(map(int, sr().split())) list map(int, sr().split()) map int sr().split() ().split () sr split N, K = lr() N lr() lr K limit = (N-1) * (N-2) // 2 limit (N-1) * (N-2) // 2 (N-1) * (N-2) N-1 N 1 N-2 N 2 2 if K > limit:
    print(-1); exit() K > limit K limit print(-1) print -1 exit() exit (1, x) for x in range(2, N+1) for x in range(2, N+1) x range(2, N+1) range 2 N+1 N 1 for x in range(2, N+1) (1, x) 1 x A = [(1, x) for x in range(2, N+1)] A [(1, x) for x in range(2, N+1)] for i, (x, y) in zip(range(limit-K), combinations(range(2, N+1), 2)):
    A.append((x, y)) i (x, y) x y zip(range(limit-K), combinations(range(2, N+1), 2)) zip range(limit-K) range limit-K limit K combinations(range(2, N+1), 2) combinations range(2, N+1) range 2 N+1 N 1 2 A.append((x, y)) A.append A append (x, y) x y print(len(A)) print len(A) len A for a in A:
    print(*a) a A print(*a) print *a a A = [(1, x) for x in range(2, N+1)] [(1, x) for x in range(2, N+1)] A lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr N, K = lr() lr() N K = lr() lr() K sr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() sr ir = lambda: int(sr()) lambda: int(sr()) ir limit = (N-1) * (N-2) // 2 (N-1) * (N-2) // 2 limit
import sys
from itertools import combinations

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
limit = (N-1) * (N-2) // 2
if K > limit:
    print(-1); exit()

A = [(1, x) for x in range(2, N+1)]
# limit - K だけ辺を引く
for i, (x, y) in zip(range(limit-K), combinations(range(2, N+1), 2)):
    A.append((x, y))

print(len(A))
for a in A:
    print(*a)
