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