N, K = map(int,input().split())
max_edge = (N-1)*(N-2)//2
all_edges = [[i,j] for i in range(N) for j in range(i+1,N)]

if 0 <= K <= max_edge:
    minus = max_edge - K
    count = 0
    answer = []
    for edge in all_edges:
        if edge[0] == 0:
            answer.append(edge)
        elif count < minus:
            answer.append(edge)
            count+=1
    print(len(answer))
    for i in range(len(answer)):
        print((" ").join(str(j+1) for j in answer[i]))
else:
    print(-1) N, K = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split K max_edge = (N-1)*(N-2)//2 max_edge (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 [i,j] for i in range(N) for j in range(i+1,N) for i in range(N) for j in range(i+1,N) i range(N) range N for j in range(i+1,N) j range(i+1,N) range i+1 i 1 N for j in range(i+1,N) [i,j] i j all_edges = [[i,j] for i in range(N) for j in range(i+1,N)] all_edges [[i,j] for i in range(N) for j in range(i+1,N)] if 0 <= K <= max_edge:
    minus = max_edge - K
    count = 0
    answer = []
    for edge in all_edges:
        if edge[0] == 0:
            answer.append(edge)
        elif count < minus:
            answer.append(edge)
            count+=1
    print(len(answer))
    for i in range(len(answer)):
        print((" ").join(str(j+1) for j in answer[i]))
else:
    print(-1) 0 <= K <= max_edge 0 <= K 0 K max_edge minus = max_edge - K minus max_edge - K max_edge K count = 0 count 0 answer = [] answer [] for edge in all_edges:
        if edge[0] == 0:
            answer.append(edge)
        elif count < minus:
            answer.append(edge)
            count+=1
     edge all_edges if edge[0] == 0:
            answer.append(edge)
        elif count < minus:
            answer.append(edge)
            count+=1
     edge[0] == 0 edge[0] edge 0 0 answer.append(edge) answer.append answer append edge elif count < minus:
            answer.append(edge)
            count+=1
     count < minus count minus answer.append(edge) answer.append answer append edge count+=1 count 1 print(len(answer)) print len(answer) len answer for i in range(len(answer)):
        print((" ").join(str(j+1) for j in answer[i])) i range(len(answer)) range len(answer) len answer print((" ").join(str(j+1) for j in answer[i])) print (" ").join(str(j+1) for j in answer[i]) " ").join " " join str(j+1) str j+1 j 1 print(-1) print -1 max_edge = (N-1)*(N-2)//2 (N-1)*(N-2)//2 max_edge minus = max_edge - K max_edge - K minus count+=1 1 count count = 0 0 count all_edges = [[i,j] for i in range(N) for j in range(i+1,N)] [[i,j] for i in range(N) for j in range(i+1,N)] all_edges answer = [] [] answer K = map(int,input().split()) map(int,input().split()) K N, K = map(int,input().split()) map(int,input().split()) N
N, K = map(int,input().split())
max_edge = (N-1)*(N-2)//2
all_edges = [[i,j] for i in range(N) for j in range(i+1,N)]

if 0 <= K <= max_edge:
    minus = max_edge - K
    count = 0
    answer = []
    for edge in all_edges:
        if edge[0] == 0:
            answer.append(edge)
        elif count < minus:
            answer.append(edge)
            count+=1
    print(len(answer))
    for i in range(len(answer)):
        print((" ").join(str(j+1) for j in answer[i]))
else:
    print(-1)