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

if k>(n-1)*(n-2)//2:
    print(-1)
else:
    c=(n-1)*(n-2)//2-k
    print(n-1+c)
    for i in range(1,n):
        print(i,n)
    for a,b in itertools.combinations(range(1,n),2):
        if c==0:
            break
        print(a,b)
        c-=1 import itertools itertools 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)
else:
    c=(n-1)*(n-2)//2-k
    print(n-1+c)
    for i in range(1,n):
        print(i,n)
    for a,b in itertools.combinations(range(1,n),2):
        if c==0:
            break
        print(a,b)
        c-=1 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 c=(n-1)*(n-2)//2-k c (n-1)*(n-2)//2-k (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 k print(n-1+c) print n-1+c n-1 n 1 c for i in range(1,n):
        print(i,n)
     i range(1,n) range 1 n print(i,n) print i n for a,b in itertools.combinations(range(1,n),2):
        if c==0:
            break
        print(a,b)
        c-=1 a b itertools.combinations(range(1,n),2) itertools.combinations itertools combinations range(1,n) range 1 n 2 if c==0:
            break
         c==0 c 0 break print(a,b) print a b c-=1 c 1 c=(n-1)*(n-2)//2-k (n-1)*(n-2)//2-k c n,k=map(int,input().split()) map(int,input().split()) n c-=1 1 c k=map(int,input().split()) map(int,input().split()) k
import itertools
n,k=map(int,input().split())

if k>(n-1)*(n-2)//2:
    print(-1)
else:
    c=(n-1)*(n-2)//2-k
    print(n-1+c)
    for i in range(1,n):
        print(i,n)
    for a,b in itertools.combinations(range(1,n),2):
        if c==0:
            break
        print(a,b)
        c-=1