# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,K = map(int,input().split())

Ans = []
for i in range(N-1):
    Ans.append((N-1,i))

cnt = (N-1)*(N-2)//2
if cnt < K:
    print(-1)
    sys.exit()

for i in range(N-1):
    for j in range(i+1,N-1):
        if cnt>K:
            Ans.append((i,j))
            cnt -= 1

print(len(Ans))
for u,v in Ans:
    print(u+1,v+1) import sys sys 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 Ans = [] Ans [] for i in range(N-1):
    Ans.append((N-1,i)) i range(N-1) range N-1 N 1 Ans.append((N-1,i)) Ans.append Ans append (N-1,i) N-1 N 1 i cnt = (N-1)*(N-2)//2 cnt (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 if cnt < K:
    print(-1)
    sys.exit() cnt < K cnt K print(-1) print -1 sys.exit() sys.exit sys exit for i in range(N-1):
    for j in range(i+1,N-1):
        if cnt>K:
            Ans.append((i,j))
            cnt -= 1 i range(N-1) range N-1 N 1 for j in range(i+1,N-1):
        if cnt>K:
            Ans.append((i,j))
            cnt -= 1 j range(i+1,N-1) range i+1 i 1 N-1 N 1 if cnt>K:
            Ans.append((i,j))
            cnt -= 1 cnt>K cnt K Ans.append((i,j)) Ans.append Ans append (i,j) i j cnt -= 1 cnt 1 print(len(Ans)) print len(Ans) len Ans for u,v in Ans:
    print(u+1,v+1) u v Ans print(u+1,v+1) print u+1 u 1 v+1 v 1 N,K = map(int,input().split()) map(int,input().split()) N Ans = [] [] Ans input = sys.stdin.readline sys.stdin.readline input cnt = (N-1)*(N-2)//2 (N-1)*(N-2)//2 cnt cnt -= 1 1 cnt K = map(int,input().split()) map(int,input().split()) K
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,K = map(int,input().split())

Ans = []
for i in range(N-1):
    Ans.append((N-1,i))

cnt = (N-1)*(N-2)//2
if cnt < K:
    print(-1)
    sys.exit()

for i in range(N-1):
    for j in range(i+1,N-1):
        if cnt>K:
            Ans.append((i,j))
            cnt -= 1

print(len(Ans))
for u,v in Ans:
    print(u+1,v+1)
