N,K = map(int,input().split(' '))

max_num = (N-2)*(N-2+1)/2
M = 0
if max_num >=K:
    base_graph = [[] for _ in range(N+1)]
    base_graph[1].append(2)
    base_graph[2].append(1)
    for i in range(3,N+1):
        base_graph[1].append(i)
        base_graph[i].append(1)
    #print(base_graph)
    M = N- 1

    idx = N
    diff = max_num-K
    while diff != 0:
        if len(base_graph[idx]) == N-1:
            idx -= 1
        else:
            insert_val = len(base_graph[idx]) + 1 - (N-idx)
            base_graph[idx].append(insert_val)
            base_graph[insert_val].append(idx)
            diff -=1
            M +=1
    print(M)
    for idx,node in enumerate(base_graph): 
        for i in node:
            if idx < i:
                print(idx,i)
        
else:
    print(-1) N,K = map(int,input().split(' ')) N map(int,input().split(' ')) map int input().split(' ') ().split () input split ' ' K max_num = (N-2)*(N-2+1)/2 max_num (N-2)*(N-2+1)/2 (N-2)*(N-2+1) N-2 N 2 N-2+1 N-2 N 2 1 2 M = 0 M 0 if max_num >=K:
    base_graph = [[] for _ in range(N+1)]
    base_graph[1].append(2)
    base_graph[2].append(1)
    for i in range(3,N+1):
        base_graph[1].append(i)
        base_graph[i].append(1)
    #print(base_graph)
    M = N- 1

    idx = N
    diff = max_num-K
    while diff != 0:
        if len(base_graph[idx]) == N-1:
            idx -= 1
        else:
            insert_val = len(base_graph[idx]) + 1 - (N-idx)
            base_graph[idx].append(insert_val)
            base_graph[insert_val].append(idx)
            diff -=1
            M +=1
    print(M)
    for idx,node in enumerate(base_graph): 
        for i in node:
            if idx < i:
                print(idx,i)
        
else:
    print(-1) max_num >=K max_num K [] for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [] base_graph = [[] for _ in range(N+1)] base_graph [[] for _ in range(N+1)] base_graph[1].append(2) [1].append [1] base_graph 1 append 2 base_graph[2].append(1) [2].append [2] base_graph 2 append 1 for i in range(3,N+1):
        base_graph[1].append(i)
        base_graph[i].append(1)
    #print(base_graph)
     i range(3,N+1) range 3 N+1 N 1 base_graph[1].append(i) [1].append [1] base_graph 1 append i base_graph[i].append(1) [i].append [i] base_graph i append 1 M = N- 1 M N- 1 N 1 idx = N idx N diff = max_num-K diff max_num-K max_num K while diff != 0:
        if len(base_graph[idx]) == N-1:
            idx -= 1
        else:
            insert_val = len(base_graph[idx]) + 1 - (N-idx)
            base_graph[idx].append(insert_val)
            base_graph[insert_val].append(idx)
            diff -=1
            M +=1
     diff != 0 diff 0 if len(base_graph[idx]) == N-1:
            idx -= 1
        else:
            insert_val = len(base_graph[idx]) + 1 - (N-idx)
            base_graph[idx].append(insert_val)
            base_graph[insert_val].append(idx)
            diff -=1
            M +=1
     len(base_graph[idx]) == N-1 len(base_graph[idx]) len base_graph[idx] base_graph idx N-1 N 1 idx -= 1 idx 1 insert_val = len(base_graph[idx]) + 1 - (N-idx) insert_val len(base_graph[idx]) + 1 - (N-idx) len(base_graph[idx]) + 1 len(base_graph[idx]) len base_graph[idx] base_graph idx 1 N-idx N idx base_graph[idx].append(insert_val) [idx].append [idx] base_graph idx append insert_val base_graph[insert_val].append(idx) [insert_val].append [insert_val] base_graph insert_val append idx diff -=1 diff 1 M +=1 M 1 print(M) print M for idx,node in enumerate(base_graph): 
        for i in node:
            if idx < i:
                print(idx,i)
         idx node enumerate(base_graph) enumerate base_graph for i in node:
            if idx < i:
                print(idx,i)
         i node if idx < i:
                print(idx,i)
         idx < i idx i print(idx,i) print idx i print(-1) print -1 max_num = (N-2)*(N-2+1)/2 (N-2)*(N-2+1)/2 max_num M = N- 1 N- 1 M insert_val = len(base_graph[idx]) + 1 - (N-idx) len(base_graph[idx]) + 1 - (N-idx) insert_val diff -=1 1 diff M +=1 1 M M = 0 0 M diff = max_num-K max_num-K diff base_graph = [[] for _ in range(N+1)] [[] for _ in range(N+1)] base_graph idx -= 1 1 idx idx = N N idx N,K = map(int,input().split(' ')) map(int,input().split(' ')) N K = map(int,input().split(' ')) map(int,input().split(' ')) K
N,K = map(int,input().split(' '))

max_num = (N-2)*(N-2+1)/2
M = 0
if max_num >=K:
    base_graph = [[] for _ in range(N+1)]
    base_graph[1].append(2)
    base_graph[2].append(1)
    for i in range(3,N+1):
        base_graph[1].append(i)
        base_graph[i].append(1)
    #print(base_graph)
    M = N- 1

    idx = N
    diff = max_num-K
    while diff != 0:
        if len(base_graph[idx]) == N-1:
            idx -= 1
        else:
            insert_val = len(base_graph[idx]) + 1 - (N-idx)
            base_graph[idx].append(insert_val)
            base_graph[insert_val].append(idx)
            diff -=1
            M +=1
    print(M)
    for idx,node in enumerate(base_graph): 
        for i in node:
            if idx < i:
                print(idx,i)
        
else:
    print(-1)