n, k = [int(x) for x in input().strip().split(" ")]
m=~-n*(n-2)//2
if k>m:
    print(-1)
else:
    m-=k
    print(m+n-1)
    for i in range(1, n):
        print(i, n)
    for i in range(1, n):
        for j in range(i+1, n):
            if m==0:
                break
            print(i, j)
            m-=1 int(x) for x in input().strip().split(" ") for x in input().strip().split(" ") x input().strip().split(" ") ().strip().split ().strip() ().strip () input strip split " " for x in input().strip().split(" ") int(x) int x n, k = [int(x) for x in input().strip().split(" ")] n [int(x) for x in input().strip().split(" ")] k m=~-n*(n-2)//2 m ~-n*(n-2)//2 ~-n*(n-2) ~-n -n n n-2 n 2 2 if k>m:
    print(-1)
else:
    m-=k
    print(m+n-1)
    for i in range(1, n):
        print(i, n)
    for i in range(1, n):
        for j in range(i+1, n):
            if m==0:
                break
            print(i, j)
            m-=1 k>m k m print(-1) print -1 m-=k m k print(m+n-1) print m+n-1 m+n m n 1 for i in range(1, n):
        print(i, n)
     i range(1, n) range 1 n print(i, n) print i n for i in range(1, n):
        for j in range(i+1, n):
            if m==0:
                break
            print(i, j)
            m-=1 i range(1, n) range 1 n for j in range(i+1, n):
            if m==0:
                break
            print(i, j)
            m-=1 j range(i+1, n) range i+1 i 1 n if m==0:
                break
             m==0 m 0 break print(i, j) print i j m-=1 m 1 k = [int(x) for x in input().strip().split(" ")] [int(x) for x in input().strip().split(" ")] k m=~-n*(n-2)//2 ~-n*(n-2)//2 m n, k = [int(x) for x in input().strip().split(" ")] [int(x) for x in input().strip().split(" ")] n m-=1 1 m m-=k k m
n, k = [int(x) for x in input().strip().split(" ")]
m=~-n*(n-2)//2
if k>m:
    print(-1)
else:
    m-=k
    print(m+n-1)
    for i in range(1, n):
        print(i, n)
    for i in range(1, n):
        for j in range(i+1, n):
            if m==0:
                break
            print(i, j)
            m-=1
