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

graph = [[] for i in range(n)]
if k > ((n-1)*(n-2))//2:
    print(-1)
else:
    for i in range(1,n):
        graph[0].append(i+1)
    
    remain = ((n-1)*(n-2))//2 - k
    for i in range(1,n):
        if remain <= 0:
            break
        for j in range(i+1,n):
            if remain > 0:
                graph[i].append(j+1)
                remain -= 1
            else:
                break

    print(((n-1)*(n-2))//2 - k + (n-1))
    for i in range(len(graph)):
        for j in range(len(graph[i])):
            print(i+1, graph[i][j])

 n,k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] graph = [[] for i in range(n)] graph [[] for i in range(n)] if k > ((n-1)*(n-2))//2:
    print(-1)
else:
    for i in range(1,n):
        graph[0].append(i+1)
    
    remain = ((n-1)*(n-2))//2 - k
    for i in range(1,n):
        if remain <= 0:
            break
        for j in range(i+1,n):
            if remain > 0:
                graph[i].append(j+1)
                remain -= 1
            else:
                break

    print(((n-1)*(n-2))//2 - k + (n-1))
    for i in range(len(graph)):
        for j in range(len(graph[i])):
            print(i+1, graph[i][j]) 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 for i in range(1,n):
        graph[0].append(i+1)
    
     i range(1,n) range 1 n graph[0].append(i+1) [0].append [0] graph 0 append i+1 i 1 remain = ((n-1)*(n-2))//2 - k remain ((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 for i in range(1,n):
        if remain <= 0:
            break
        for j in range(i+1,n):
            if remain > 0:
                graph[i].append(j+1)
                remain -= 1
            else:
                break

     i range(1,n) range 1 n if remain <= 0:
            break
         remain <= 0 remain 0 break for j in range(i+1,n):
            if remain > 0:
                graph[i].append(j+1)
                remain -= 1
            else:
                break

     j range(i+1,n) range i+1 i 1 n if remain > 0:
                graph[i].append(j+1)
                remain -= 1
            else:
                break

     remain > 0 remain 0 graph[i].append(j+1) [i].append [i] graph i append j+1 j 1 remain -= 1 remain 1 break print(((n-1)*(n-2))//2 - k + (n-1)) print ((n-1)*(n-2))//2 - k + (n-1) ((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 n-1 n 1 for i in range(len(graph)):
        for j in range(len(graph[i])):
            print(i+1, graph[i][j]) i range(len(graph)) range len(graph) len graph for j in range(len(graph[i])):
            print(i+1, graph[i][j]) j range(len(graph[i])) range len(graph[i]) len graph[i] graph i print(i+1, graph[i][j]) print i+1 i 1 graph[i][j] [i] graph i j n,k = map(int, input().split()) map(int, input().split()) n k = map(int, input().split()) map(int, input().split()) k remain = ((n-1)*(n-2))//2 - k ((n-1)*(n-2))//2 - k remain graph = [[] for i in range(n)] [[] for i in range(n)] graph remain -= 1 1 remain
n,k = map(int, input().split())

graph = [[] for i in range(n)]
if k > ((n-1)*(n-2))//2:
    print(-1)
else:
    for i in range(1,n):
        graph[0].append(i+1)
    
    remain = ((n-1)*(n-2))//2 - k
    for i in range(1,n):
        if remain <= 0:
            break
        for j in range(i+1,n):
            if remain > 0:
                graph[i].append(j+1)
                remain -= 1
            else:
                break

    print(((n-1)*(n-2))//2 - k + (n-1))
    for i in range(len(graph)):
        for j in range(len(graph[i])):
            print(i+1, graph[i][j])


