# -*- coding: utf-8 -*-
#E - Friendships
import sys 
from itertools import combinations
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を頂点とするスターグラフを考える
    x = (N-1)*(N-2)//2
    rest = x-K
    ans = [(x,N) for x in range(1,N)] + list(combinations(range(1,N),2))
    ans = ans[:N-1+rest]
    print(len(ans))
    for x,y in ans:
        print(x,y) import sys sys from itertools import combinations 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を頂点とするスターグラフを考える
    x = (N-1)*(N-2)//2
    rest = x-K
    ans = [(x,N) for x in range(1,N)] + list(combinations(range(1,N),2))
    ans = ans[:N-1+rest]
    print(len(ans))
    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 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 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 ans = [(x,N) for x in range(1,N)] + list(combinations(range(1,N),2)) ans [(x,N) for x in range(1,N)] + list(combinations(range(1,N),2)) [(x,N) for x in range(1,N)] list(combinations(range(1,N),2)) list combinations(range(1,N),2) combinations range(1,N) range 1 N 2 ans = ans[:N-1+rest] ans ans[:N-1+rest] ans :N-1+rest N-1+rest N-1 N 1 rest print(len(ans)) print len(ans) len ans for x,y in ans:
        print(x,y) x y ans print(x,y) print x y readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines read = sys.stdin.buffer.read sys.stdin.buffer.read read x = (N-1)*(N-2)//2 (N-1)*(N-2)//2 x ans = [(x,N) for x in range(1,N)] + list(combinations(range(1,N),2)) [(x,N) for x in range(1,N)] + list(combinations(range(1,N),2)) ans N, K = map(int,readline().split()) map(int,readline().split()) N K = map(int,readline().split()) map(int,readline().split()) K ans = ans[:N-1+rest] ans[:N-1+rest] ans rest = x-K x-K rest readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline
# -*- coding: utf-8 -*-
#E - Friendships
import sys 
from itertools import combinations
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を頂点とするスターグラフを考える
    x = (N-1)*(N-2)//2
    rest = x-K
    ans = [(x,N) for x in range(1,N)] + list(combinations(range(1,N),2))
    ans = ans[:N-1+rest]
    print(len(ans))
    for x,y in ans:
        print(x,y)