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