import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N, K = rl()

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

ans = []
for i in range(1, N):
	ans.append((1, i+1))
remains = []
for i in range(1, N):
	for j in range(i+1, N):
		remains.append((i+1, j+1))
k = m-K
for i in range(k):
	ans.append(remains[i])
print(len(ans))
for p in ans:
	print(*p) import sys, math sys math from collections import defaultdict, deque, Counter from bisect import bisect_left, bisect_right from itertools import combinations, permutations, product from heapq import heappush, heappop from functools import lru_cache input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline rs = lambda: input().strip() rs lambda: input().strip() input().strip() ().strip () input strip ri = lambda: int(input()) ri lambda: int(input()) int(input()) int input() input rl = lambda: list(map(int, input().split())) rl lambda: list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split mod = 1000000007 mod 1000000007 sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 N, K = rl() N rl() rl K m = (N-1)*(N-2)//2 m (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 if K > m:
	print(-1)
	exit() K > m K m print(-1) print -1 exit() exit ans = [] ans [] for i in range(1, N):
	ans.append((1, i+1)) i range(1, N) range 1 N ans.append((1, i+1)) ans.append ans append (1, i+1) 1 i+1 i 1 remains = [] remains [] for i in range(1, N):
	for j in range(i+1, N):
		remains.append((i+1, j+1)) i range(1, N) range 1 N for j in range(i+1, N):
		remains.append((i+1, j+1)) j range(i+1, N) range i+1 i 1 N remains.append((i+1, j+1)) remains.append remains append (i+1, j+1) i+1 i 1 j+1 j 1 k = m-K k m-K m K for i in range(k):
	ans.append(remains[i]) i range(k) range k ans.append(remains[i]) ans.append ans append remains[i] remains i print(len(ans)) print len(ans) len ans for p in ans:
	print(*p) p ans print(*p) print *p p rs = lambda: input().strip() lambda: input().strip() rs k = m-K m-K k ri = lambda: int(input()) lambda: int(input()) ri N, K = rl() rl() N remains = [] [] remains K = rl() rl() K m = (N-1)*(N-2)//2 (N-1)*(N-2)//2 m mod = 1000000007 1000000007 mod input = sys.stdin.readline sys.stdin.readline input ans = [] [] ans rl = lambda: list(map(int, input().split())) lambda: list(map(int, input().split())) rl
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N, K = rl()

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

ans = []
for i in range(1, N):
	ans.append((1, i+1))
remains = []
for i in range(1, N):
	for j in range(i+1, N):
		remains.append((i+1, j+1))
k = m-K
for i in range(k):
	ans.append(remains[i])
print(len(ans))
for p in ans:
	print(*p)
