# -*- coding: utf-8 -*-
#E - Friendships
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K = map(int,readline().split())
if K > (N-1)*(N-2)//2:
    print(-1)
else:
    # Nを頂点とするスターグラフを考える
    ans = []
    for i in range(1,N):
        ans.append((i,N))
    M = N*(N-1)//2 - K
    cnt = N-1
    flag = False
    for i in range(1,N):
        for j in range(i+1,N):
            if cnt == M:
                flag = True
                break
            ans.append((i,j))
            cnt += 1
        if flag:
            break
    print(M)
    for x,y in ans:
        print(x,y) import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines N, K = map(int,readline().split()) N map(int,readline().split()) map int readline().split() ().split () readline split K if K > (N-1)*(N-2)//2:
    print(-1)
else:
    # Nを頂点とするスターグラフを考える
    ans = []
    for i in range(1,N):
        ans.append((i,N))
    M = N*(N-1)//2 - K
    cnt = N-1
    flag = False
    for i in range(1,N):
        for j in range(i+1,N):
            if cnt == M:
                flag = True
                break
            ans.append((i,j))
            cnt += 1
        if flag:
            break
    print(M)
    for x,y in ans:
        print(x,y) 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 ans = [] ans [] for i in range(1,N):
        ans.append((i,N))
     i range(1,N) range 1 N ans.append((i,N)) ans.append ans append (i,N) i N M = N*(N-1)//2 - K M N*(N-1)//2 - K N*(N-1)//2 N*(N-1) N N-1 N 1 2 K cnt = N-1 cnt N-1 N 1 flag = False flag False for i in range(1,N):
        for j in range(i+1,N):
            if cnt == M:
                flag = True
                break
            ans.append((i,j))
            cnt += 1
        if flag:
            break
     i range(1,N) range 1 N for j in range(i+1,N):
            if cnt == M:
                flag = True
                break
            ans.append((i,j))
            cnt += 1
         j range(i+1,N) range i+1 i 1 N if cnt == M:
                flag = True
                break
             cnt == M cnt M flag = True flag True break ans.append((i,j)) ans.append ans append (i,j) i j cnt += 1 cnt 1 if flag:
            break
     flag break print(M) print M for x,y in ans:
        print(x,y) x y ans print(x,y) print x y N, K = map(int,readline().split()) map(int,readline().split()) N ans = [] [] ans flag = False False flag flag = True True flag K = map(int,readline().split()) map(int,readline().split()) K cnt += 1 1 cnt M = N*(N-1)//2 - K N*(N-1)//2 - K M cnt = N-1 N-1 cnt readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines read = sys.stdin.buffer.read sys.stdin.buffer.read read readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline
# -*- coding: utf-8 -*-
#E - Friendships
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K = map(int,readline().split())
if K > (N-1)*(N-2)//2:
    print(-1)
else:
    # Nを頂点とするスターグラフを考える
    ans = []
    for i in range(1,N):
        ans.append((i,N))
    M = N*(N-1)//2 - K
    cnt = N-1
    flag = False
    for i in range(1,N):
        for j in range(i+1,N):
            if cnt == M:
                flag = True
                break
            ans.append((i,j))
            cnt += 1
        if flag:
            break
    print(M)
    for x,y in ans:
        print(x,y)