from itertools import combinations
n, k = map(int, input().split())
if k > ((n-1)*(n-2))//2:
    print(-1)
    exit()

edges = []
for i in range(2, n+1):  # 1を中心としたスター型グラフ
    edges.append((1, i))
dist_2 = ((n-1)*(n-2))//2
list_2 = list(combinations(range(2, n+1), 2))
#print(list_2)
for i in range(dist_2-k):
    edges.append(list_2[i])


def ans(lis):
    print(len(lis))
    for x, y in lis:
        print(x, y)
ans(edges) from itertools import combinations 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(2, n+1):  # 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 dist_2 = ((n-1)*(n-2))//2 dist_2 ((n-1)*(n-2))//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 list_2 = list(combinations(range(2, n+1), 2)) list_2 list(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 for i in range(dist_2-k):
    edges.append(list_2[i]) i range(dist_2-k) range dist_2-k dist_2 k edges.append(list_2[i]) edges.append edges append list_2[i] list_2 i def ans(lis):
    print(len(lis))
    for x, y in lis:
        print(x, y) ans print(len(lis)) print len(lis) len lis for x, y in lis:
        print(x, y) x y lis print(x, y) print x y lis lis ans(edges) ans edges edges = [] [] edges list_2 = list(combinations(range(2, n+1), 2)) list(combinations(range(2, n+1), 2)) list_2 n, k = map(int, input().split()) map(int, input().split()) n dist_2 = ((n-1)*(n-2))//2 ((n-1)*(n-2))//2 dist_2 def ans(lis):
    print(len(lis))
    for x, y in lis:
        print(x, y) def ans(lis):
    print(len(lis))
    for x, y in lis:
        print(x, y) ans k = map(int, input().split()) map(int, input().split()) k
from itertools import combinations
n, k = map(int, input().split())
if k > ((n-1)*(n-2))//2:
    print(-1)
    exit()

edges = []
for i in range(2, n+1):  # 1を中心としたスター型グラフ
    edges.append((1, i))
dist_2 = ((n-1)*(n-2))//2
list_2 = list(combinations(range(2, n+1), 2))
#print(list_2)
for i in range(dist_2-k):
    edges.append(list_2[i])


def ans(lis):
    print(len(lis))
    for x, y in lis:
        print(x, y)
ans(edges)
