from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()

if k > (n-1)*(n-2)//2:
    print(-1)
    quit()
res = []
for i in range(n-1):
    res.append([1,2+i])
l = (n-1)*(n-2)//2 - k

ind = 2

def p():
    m = len(res)
    print(m)
    for i in range(m):
        print(*res[i])
if l == 0 :
    p(); quit()
for i in range(ind,n):
    for j in range(i+1,n+1):
        res.append([i,j])
        l -= 1
        if l == 0:
            p()
            quit()
    ind += 1 from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,pprint,fractions sys bisect math itertools pprint fractions sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 INF = float('inf') INF float('inf') float 'inf' def inp(): return int(sys.stdin.readline()) inp def inpl(): return list(map(int, sys.stdin.readline().split())) inpl n,k = inpl() n inpl() inpl k if k > (n-1)*(n-2)//2:
    print(-1)
    quit() 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 quit() quit res = [] res [] for i in range(n-1):
    res.append([1,2+i]) i range(n-1) range n-1 n 1 res.append([1,2+i]) res.append res append [1,2+i] 1 2+i 2 i l = (n-1)*(n-2)//2 - k l (n-1)*(n-2)//2 - k (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 k ind = 2 ind 2 def p():
    m = len(res)
    print(m)
    for i in range(m):
        print(*res[i]) p m = len(res) m len(res) len res print(m) print m for i in range(m):
        print(*res[i]) i range(m) range m print(*res[i]) print *res[i] res[i] res i if l == 0 :
    p(); quit() l == 0 l 0 p() p quit() quit for i in range(ind,n):
    for j in range(i+1,n+1):
        res.append([i,j])
        l -= 1
        if l == 0:
            p()
            quit()
    ind += 1 i range(ind,n) range ind n for j in range(i+1,n+1):
        res.append([i,j])
        l -= 1
        if l == 0:
            p()
            quit()
     j range(i+1,n+1) range i+1 i 1 n+1 n 1 res.append([i,j]) res.append res append [i,j] i j l -= 1 l 1 if l == 0:
            p()
            quit()
     l == 0 l 0 p() p quit() quit ind += 1 ind 1 INF = float('inf') float('inf') INF def p():
    m = len(res)
    print(m)
    for i in range(m):
        print(*res[i]) def p():
    m = len(res)
    print(m)
    for i in range(m):
        print(*res[i]) p ind = 2 2 ind n,k = inpl() inpl() n res = [] [] res l = (n-1)*(n-2)//2 - k (n-1)*(n-2)//2 - k l ind += 1 1 ind mod = 10**9+7 10**9+7 mod def inp(): return int(sys.stdin.readline()) def inp(): return int(sys.stdin.readline()) inp k = inpl() inpl() k l -= 1 1 l def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl(): return list(map(int, sys.stdin.readline().split())) inpl
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()

if k > (n-1)*(n-2)//2:
    print(-1)
    quit()
res = []
for i in range(n-1):
    res.append([1,2+i])
l = (n-1)*(n-2)//2 - k

ind = 2

def p():
    m = len(res)
    print(m)
    for i in range(m):
        print(*res[i])
if l == 0 :
    p(); quit()
for i in range(ind,n):
    for j in range(i+1,n+1):
        res.append([i,j])
        l -= 1
        if l == 0:
            p()
            quit()
    ind += 1
