import sys
N, K = map(int, input().split())
MAXP = (N - 1) * (N - 2) // 2
res = MAXP - K

if res < 0:
    print(-1)
    sys.exit()

M = (N - 1) + res

root = 2
end = root + 1

print(M)
for i in range(2,N+1):
    print(1, i)

for _ in range(res):
    if end > N:
        root += 1
        end = root + 1
    print(root, end)
    end += 1 import sys sys N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K MAXP = (N - 1) * (N - 2) // 2 MAXP (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 res = MAXP - K res MAXP - K MAXP K if res < 0:
    print(-1)
    sys.exit() res < 0 res 0 print(-1) print -1 sys.exit() sys.exit sys exit M = (N - 1) + res M (N - 1) + res N - 1 N 1 res root = 2 root 2 end = root + 1 end root + 1 root 1 print(M) print M for i in range(2,N+1):
    print(1, i) i range(2,N+1) range 2 N+1 N 1 print(1, i) print 1 i for _ in range(res):
    if end > N:
        root += 1
        end = root + 1
    print(root, end)
    end += 1 _ range(res) range res if end > N:
        root += 1
        end = root + 1
     end > N end N root += 1 root 1 end = root + 1 end root + 1 root 1 print(root, end) print root end end += 1 end 1 MAXP = (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) // 2 MAXP M = (N - 1) + res (N - 1) + res M end = root + 1 root + 1 end end += 1 1 end N, K = map(int, input().split()) map(int, input().split()) N root = 2 2 root K = map(int, input().split()) map(int, input().split()) K res = MAXP - K MAXP - K res root += 1 1 root end = root + 1 root + 1 end
import sys
N, K = map(int, input().split())
MAXP = (N - 1) * (N - 2) // 2
res = MAXP - K

if res < 0:
    print(-1)
    sys.exit()

M = (N - 1) + res

root = 2
end = root + 1

print(M)
for i in range(2,N+1):
    print(1, i)

for _ in range(res):
    if end > N:
        root += 1
        end = root + 1
    print(root, end)
    end += 1