from itertools import combinations

# 自分の答案に組み込んで見る
a,b = map(int,input().split())

S  = (a-1)*(a-2)//2
def solve(x,y,s):
    print(a+s-y-1)
    for i in range(1,a):print(1,1+i)
    c = s-b
    edges = list(combinations(range(2, a+1), 2))[:c]
    for i, j in edges:
        print(i, j)
# print(b,S)
if not 0<= b <= S:
    print(-1)
    exit()
else:
    solve(a,b,S) from itertools import combinations a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b S  = (a-1)*(a-2)//2 S (a-1)*(a-2)//2 (a-1)*(a-2) a-1 a 1 a-2 a 2 2 def solve(x,y,s):
    print(a+s-y-1)
    for i in range(1,a):print(1,1+i)
    c = s-b
    edges = list(combinations(range(2, a+1), 2))[:c]
    for i, j in edges:
        print(i, j)
# print(b,S) solve print(a+s-y-1) print a+s-y-1 a+s-y a+s a s y 1 for i in range(1,a):print(1,1+i)
     i range(1,a) range 1 a c = s-b c s-b s b edges = list(combinations(range(2, a+1), 2))[:c] edges list(combinations(range(2, a+1), 2))[:c] (combinations(range(2, a+1), 2)) list combinations(range(2, a+1), 2) combinations range(2, a+1) range 2 a+1 a 1 2 :c c for i, j in edges:
        print(i, j)
# print(b,S) i j edges print(i, j) print i j x x y y s s if not 0<= b <= S:
    print(-1)
    exit()
else:
    solve(a,b,S) not 0<= b <= S 0<= b <= S 0<= b 0 b S print(-1) print -1 exit() exit solve(a,b,S) solve a b S a,b = map(int,input().split()) map(int,input().split()) a S  = (a-1)*(a-2)//2 (a-1)*(a-2)//2 S def solve(x,y,s):
    print(a+s-y-1)
    for i in range(1,a):print(1,1+i)
    c = s-b
    edges = list(combinations(range(2, a+1), 2))[:c]
    for i, j in edges:
        print(i, j)
# print(b,S) def solve(x,y,s):
    print(a+s-y-1)
    for i in range(1,a):print(1,1+i)
    c = s-b
    edges = list(combinations(range(2, a+1), 2))[:c]
    for i, j in edges:
        print(i, j)
# print(b,S) solve b = map(int,input().split()) map(int,input().split()) b
from itertools import combinations

# 自分の答案に組み込んで見る
a,b = map(int,input().split())

S  = (a-1)*(a-2)//2
def solve(x,y,s):
    print(a+s-y-1)
    for i in range(1,a):print(1,1+i)
    c = s-b
    edges = list(combinations(range(2, a+1), 2))[:c]
    for i, j in edges:
        print(i, j)
# print(b,S)
if not 0<= b <= S:
    print(-1)
    exit()
else:
    solve(a,b,S)
