import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

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

x = (N-1)*(N-2)//2
if K > (N-1)*(N-2)//2:
    print(-1)
    exit()

rest = x-K
UV = [(x,N) for x in range(1,N)] + list(itertools.combinations(range(1,N),2))
UV = UV[:N-1+rest]

print(len(UV))
print('\n'.join('{} {}'.format(x,y) for x,y in UV)) 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 import itertools itertools N,K = map(int,read().split()) N map(int,read().split()) map int read().split() ().split () read split K x = (N-1)*(N-2)//2 x (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 if K > (N-1)*(N-2)//2:
    print(-1)
    exit() 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 exit() exit rest = x-K rest x-K x K (x,N) for x in range(1,N) for x in range(1,N) x range(1,N) range 1 N for x in range(1,N) (x,N) x N UV = [(x,N) for x in range(1,N)] + list(itertools.combinations(range(1,N),2)) UV [(x,N) for x in range(1,N)] + list(itertools.combinations(range(1,N),2)) [(x,N) for x in range(1,N)] list(itertools.combinations(range(1,N),2)) list itertools.combinations(range(1,N),2) itertools.combinations itertools combinations range(1,N) range 1 N 2 UV = UV[:N-1+rest] UV UV[:N-1+rest] UV :N-1+rest N-1+rest N-1 N 1 rest print(len(UV)) print len(UV) len UV print('\n'.join('{} {}'.format(x,y) for x,y in UV)) print '\n'.join('{} {}'.format(x,y) for x,y in UV) '\n'.join '\n' join '{} {}'.format(x,y) '{} {}'.format '{} {}' format x y K = map(int,read().split()) map(int,read().split()) K x = (N-1)*(N-2)//2 (N-1)*(N-2)//2 x read = sys.stdin.buffer.read sys.stdin.buffer.read read readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines UV = UV[:N-1+rest] UV[:N-1+rest] UV N,K = map(int,read().split()) map(int,read().split()) N UV = [(x,N) for x in range(1,N)] + list(itertools.combinations(range(1,N),2)) [(x,N) for x in range(1,N)] + list(itertools.combinations(range(1,N),2)) UV rest = x-K x-K rest readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

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

x = (N-1)*(N-2)//2
if K > (N-1)*(N-2)//2:
    print(-1)
    exit()

rest = x-K
UV = [(x,N) for x in range(1,N)] + list(itertools.combinations(range(1,N),2))
UV = UV[:N-1+rest]

print(len(UV))
print('\n'.join('{} {}'.format(x,y) for x,y in UV))