from itertools import combinations
N,K=map(int, input().split())
M=(N-1)*(N-2)//2
if K>M:
    print(-1)
else:
    E=[]
    for i in range(2,N+1):
        E.append((1,i))
    E+=list(combinations(range(2,N+1), 2))[:M-K]
    print(len(E))
    for e in E:
        print(*e) from itertools import combinations N,K=map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K M=(N-1)*(N-2)//2 M (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 if K>M:
    print(-1)
else:
    E=[]
    for i in range(2,N+1):
        E.append((1,i))
    E+=list(combinations(range(2,N+1), 2))[:M-K]
    print(len(E))
    for e in E:
        print(*e) K>M K M print(-1) print -1 E=[] E [] for i in range(2,N+1):
        E.append((1,i))
     i range(2,N+1) range 2 N+1 N 1 E.append((1,i)) E.append E append (1,i) 1 i E+=list(combinations(range(2,N+1), 2))[:M-K] E list(combinations(range(2,N+1), 2))[:M-K] (combinations(range(2,N+1), 2)) list combinations(range(2,N+1), 2) combinations range(2,N+1) range 2 N+1 N 1 2 :M-K M-K M K print(len(E)) print len(E) len E for e in E:
        print(*e) e E print(*e) print *e e N,K=map(int, input().split()) map(int, input().split()) N E=[] [] E M=(N-1)*(N-2)//2 (N-1)*(N-2)//2 M E+=list(combinations(range(2,N+1), 2))[:M-K] list(combinations(range(2,N+1), 2))[:M-K] E K=map(int, input().split()) map(int, input().split()) K
from itertools import combinations
N,K=map(int, input().split())
M=(N-1)*(N-2)//2
if K>M:
    print(-1)
else:
    E=[]
    for i in range(2,N+1):
        E.append((1,i))
    E+=list(combinations(range(2,N+1), 2))[:M-K]
    print(len(E))
    for e in E:
        print(*e)