N,K = map(int,input().split())
if K>((N-1)*(N-2))//2:
    print(-1)
else:
    print((N*(N-1))//2-K)
    for i in range(1,N):
        print(i,N)
    cnt = 0
    for i in range(1,N-1):
        for j in range(i+1,N):
            if cnt>=K:
                print(i,j)
            else:
                cnt += 1 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:
    print((N*(N-1))//2-K)
    for i in range(1,N):
        print(i,N)
    cnt = 0
    for i in range(1,N-1):
        for j in range(i+1,N):
            if cnt>=K:
                print(i,j)
            else:
                cnt += 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 print((N*(N-1))//2-K) print (N*(N-1))//2-K (N*(N-1))//2 N*(N-1) N N-1 N 1 2 K for i in range(1,N):
        print(i,N)
     i range(1,N) range 1 N print(i,N) print i N cnt = 0 cnt 0 for i in range(1,N-1):
        for j in range(i+1,N):
            if cnt>=K:
                print(i,j)
            else:
                cnt += 1 i range(1,N-1) range 1 N-1 N 1 for j in range(i+1,N):
            if cnt>=K:
                print(i,j)
            else:
                cnt += 1 j range(i+1,N) range i+1 i 1 N if cnt>=K:
                print(i,j)
            else:
                cnt += 1 cnt>=K cnt K print(i,j) print i j cnt += 1 cnt 1 K = map(int,input().split()) map(int,input().split()) K N,K = map(int,input().split()) map(int,input().split()) N cnt = 0 0 cnt cnt += 1 1 cnt
N,K = map(int,input().split())
if K>((N-1)*(N-2))//2:
    print(-1)
else:
    print((N*(N-1))//2-K)
    for i in range(1,N):
        print(i,N)
    cnt = 0
    for i in range(1,N-1):
        for j in range(i+1,N):
            if cnt>=K:
                print(i,j)
            else:
                cnt += 1