#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k=map(int,input().split())
G=[]
for i in range(2,n+1):
    G.append((1,i))
s=(n-1)*(n-2)//2
if k > s:
    print(-1); exit()
for i in range(2,n):
    for j in range(i+1,n+1):
        if count < s-k:
            G.append((i,j))
            count += 1

print(len(G))
for gi in G:
    print(*gi)


 import sys, math, itertools, collections, bisect sys math itertools collections bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') input lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.stdin.buffer.readline().rstrip().decode sys.stdin.buffer.readline().rstrip() sys.stdin.buffer.readline().rstrip sys.stdin.buffer.readline() sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline rstrip decode 'utf-8' inf = float('inf') inf float('inf') float 'inf' mod = 10**9+7 mod 10**9+7 10**9 10 9 7 mans = inf mans inf ans = 0 ans 0 count = 0 count 0 pro = 1 pro 1 n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k G=[] G [] for i in range(2,n+1):
    G.append((1,i)) i range(2,n+1) range 2 n+1 n 1 G.append((1,i)) G.append G append (1,i) 1 i s=(n-1)*(n-2)//2 s (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 if k > s:
    print(-1); exit() k > s k s print(-1) print -1 exit() exit for i in range(2,n):
    for j in range(i+1,n+1):
        if count < s-k:
            G.append((i,j))
            count += 1 i range(2,n) range 2 n for j in range(i+1,n+1):
        if count < s-k:
            G.append((i,j))
            count += 1 j range(i+1,n+1) range i+1 i 1 n+1 n 1 if count < s-k:
            G.append((i,j))
            count += 1 count < s-k count s-k s k G.append((i,j)) G.append G append (i,j) i j count += 1 count 1 print(len(G)) print len(G) len G for gi in G:
    print(*gi) gi G print(*gi) print *gi gi ans = 0 0 ans count = 0 0 count s=(n-1)*(n-2)//2 (n-1)*(n-2)//2 s input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') input n,k=map(int,input().split()) map(int,input().split()) n count += 1 1 count pro = 1 1 pro inf = float('inf') float('inf') inf k=map(int,input().split()) map(int,input().split()) k G=[] [] G mod = 10**9+7 10**9+7 mod mans = inf inf mans
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k=map(int,input().split())
G=[]
for i in range(2,n+1):
    G.append((1,i))
s=(n-1)*(n-2)//2
if k > s:
    print(-1); exit()
for i in range(2,n):
    for j in range(i+1,n+1):
        if count < s-k:
            G.append((i,j))
            count += 1

print(len(G))
for gi in G:
    print(*gi)



