import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

n,k = map(int,input().split())

mx=(n-1)*(n-2)//2

if mx < k:print(-1);exit()

ans=[]
for i in range(n-1):
    ans.append((i+1,n))


add=mx-k

edge=[]
for i in range(n-1):
    for j in range(i):
        edge.append((i+1,j+1))
for i in range(add):
    ans.append(edge[i])

print(len(ans))
for i in ans:
    print(*i) import sys sys sys.setrecursionlimit(10000000) sys.setrecursionlimit sys setrecursionlimit 10000000 input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n,k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k mx=(n-1)*(n-2)//2 mx (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 if mx < k:print(-1);exit() mx < k mx k ans=[] ans [] for i in range(n-1):
    ans.append((i+1,n)) i range(n-1) range n-1 n 1 ans.append((i+1,n)) ans.append ans append (i+1,n) i+1 i 1 n add=mx-k add mx-k mx k edge=[] edge [] for i in range(n-1):
    for j in range(i):
        edge.append((i+1,j+1)) i range(n-1) range n-1 n 1 for j in range(i):
        edge.append((i+1,j+1)) j range(i) range i edge.append((i+1,j+1)) edge.append edge append (i+1,j+1) i+1 i 1 j+1 j 1 for i in range(add):
    ans.append(edge[i]) i range(add) range add ans.append(edge[i]) ans.append ans append edge[i] edge i print(len(ans)) print len(ans) len ans for i in ans:
    print(*i) i ans print(*i) print *i i k = map(int,input().split()) map(int,input().split()) k ans=[] [] ans n,k = map(int,input().split()) map(int,input().split()) n mx=(n-1)*(n-2)//2 (n-1)*(n-2)//2 mx edge=[] [] edge input=sys.stdin.readline sys.stdin.readline input add=mx-k mx-k add
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

n,k = map(int,input().split())

mx=(n-1)*(n-2)//2

if mx < k:print(-1);exit()

ans=[]
for i in range(n-1):
    ans.append((i+1,n))


add=mx-k

edge=[]
for i in range(n-1):
    for j in range(i):
        edge.append((i+1,j+1))
for i in range(add):
    ans.append(edge[i])

print(len(ans))
for i in ans:
    print(*i)