# -*- coding: utf-8 -*-
import sys
import itertools
N,K=map(int, sys.stdin.readline().split())
cnt=(N-1)*(N-2)/2 #距離2の組み合わせができる最大の通り数
if cnt<K:
    print -1
    quit()
L=list( itertools.combinations(range(1,N+1),2) )

M=N-1+cnt-K
print M
for i in range(N-1):
    print L[i][0],L[i][1]

for i in range(N-1,N-1+cnt-K):
    print L[i][0],L[i][1] import sys sys import itertools itertools N,K=map(int, sys.stdin.readline().split()) N map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split K cnt=(N-1)*(N-2)/2 cnt (N-1)*(N-2)/2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 if cnt<K:
    print -1
    quit() cnt<K cnt K print -1 print 1 quit() quit L=list( itertools.combinations(range(1,N+1),2) ) L list( itertools.combinations(range(1,N+1),2) ) list itertools.combinations(range(1,N+1),2) itertools.combinations itertools combinations range(1,N+1) range 1 N+1 N 1 2 M=N-1+cnt-K M N-1+cnt-K N-1+cnt N-1 N 1 cnt K print for i in range(N-1):
    print L[i][0],L[i][1] i range(N-1) range N-1 N 1 print L[i][0] [i] L i 0 L[i][1] [i] L i 1 for i in range(N-1,N-1+cnt-K):
    print L[i][0],L[i][1] i range(N-1,N-1+cnt-K) range N-1 N 1 N-1+cnt-K N-1+cnt N-1 N 1 cnt K print L[i][0] [i] L i 0 L[i][1] [i] L i 1 K=map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) K M=N-1+cnt-K N-1+cnt-K M N,K=map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) N L=list( itertools.combinations(range(1,N+1),2) ) list( itertools.combinations(range(1,N+1),2) ) L cnt=(N-1)*(N-2)/2 (N-1)*(N-2)/2 cnt
# -*- coding: utf-8 -*-
import sys
import itertools
N,K=map(int, sys.stdin.readline().split())
cnt=(N-1)*(N-2)/2 #距離2の組み合わせができる最大の通り数
if cnt<K:
    print -1
    quit()
L=list( itertools.combinations(range(1,N+1),2) )

M=N-1+cnt-K
print M
for i in range(N-1):
    print L[i][0],L[i][1]

for i in range(N-1,N-1+cnt-K):
    print L[i][0],L[i][1]
