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

#初期状態
node = [[] for _ in range(N)]
node[0] = [i for i in range(1,N)]

if K > N*(N-1)//2 - (N-1):
    print(-1)
else:
    cnt = 0
    for i in range(1,N):
        if cnt >= N*(N-1)//2-(N-1)-K:
            break
        for j in range(i+1,N):
            if cnt >= N*(N-1)//2-(N-1)-K:
                break
            node[i].append(j)
            cnt += 1
    
    print(N-1+cnt)
    for n in range(N):
        for t in node[n]:
            print(n+1,t+1) N, K = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split K [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] node = [[] for _ in range(N)] node [[] for _ in range(N)] i for i in range(1,N) for i in range(1,N) i range(1,N) range 1 N for i in range(1,N) i node[0] = [i for i in range(1,N)] node[0] node 0 [i for i in range(1,N)] if K > N*(N-1)//2 - (N-1):
    print(-1)
else:
    cnt = 0
    for i in range(1,N):
        if cnt >= N*(N-1)//2-(N-1)-K:
            break
        for j in range(i+1,N):
            if cnt >= N*(N-1)//2-(N-1)-K:
                break
            node[i].append(j)
            cnt += 1
    
    print(N-1+cnt)
    for n in range(N):
        for t in node[n]:
            print(n+1,t+1) K > N*(N-1)//2 - (N-1) K N*(N-1)//2 - (N-1) N*(N-1)//2 N*(N-1) N N-1 N 1 2 N-1 N 1 print(-1) print -1 cnt = 0 cnt 0 for i in range(1,N):
        if cnt >= N*(N-1)//2-(N-1)-K:
            break
        for j in range(i+1,N):
            if cnt >= N*(N-1)//2-(N-1)-K:
                break
            node[i].append(j)
            cnt += 1
    
     i range(1,N) range 1 N if cnt >= N*(N-1)//2-(N-1)-K:
            break
         cnt >= N*(N-1)//2-(N-1)-K cnt N*(N-1)//2-(N-1)-K N*(N-1)//2-(N-1) N*(N-1)//2 N*(N-1) N N-1 N 1 2 N-1 N 1 K break for j in range(i+1,N):
            if cnt >= N*(N-1)//2-(N-1)-K:
                break
            node[i].append(j)
            cnt += 1
    
     j range(i+1,N) range i+1 i 1 N if cnt >= N*(N-1)//2-(N-1)-K:
                break
             cnt >= N*(N-1)//2-(N-1)-K cnt N*(N-1)//2-(N-1)-K N*(N-1)//2-(N-1) N*(N-1)//2 N*(N-1) N N-1 N 1 2 N-1 N 1 K break node[i].append(j) [i].append [i] node i append j cnt += 1 cnt 1 print(N-1+cnt) print N-1+cnt N-1 N 1 cnt for n in range(N):
        for t in node[n]:
            print(n+1,t+1) n range(N) range N for t in node[n]:
            print(n+1,t+1) t node[n] node n print(n+1,t+1) print n+1 n 1 t+1 t 1 N, K = map(int,input().split()) map(int,input().split()) N cnt = 0 0 cnt cnt += 1 1 cnt node = [[] for _ in range(N)] [[] for _ in range(N)] node K = map(int,input().split()) map(int,input().split()) K
N, K = map(int,input().split())

#初期状態
node = [[] for _ in range(N)]
node[0] = [i for i in range(1,N)]

if K > N*(N-1)//2 - (N-1):
    print(-1)
else:
    cnt = 0
    for i in range(1,N):
        if cnt >= N*(N-1)//2-(N-1)-K:
            break
        for j in range(i+1,N):
            if cnt >= N*(N-1)//2-(N-1)-K:
                break
            node[i].append(j)
            cnt += 1
    
    print(N-1+cnt)
    for n in range(N):
        for t in node[n]:
            print(n+1,t+1)