#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
INF = float("inf")

def main():
    N, K = LI()

    if (N == 2 and K == 0):
        print(1)
        print(1, 2)
        return

    if ((N-1 < 2) or comb(N-1, 2) < K):
        print(-1)
        return
    maxpairs = comb(N-1, 2)

    edges = [[] for _ in range(N)]
    edges[0] = list(range(1, N))

    pairs = list(itertools.combinations(range(1, N), 2))

    for _ in range(maxpairs - K):
        a, b = pairs.pop()
        edges[a].append(b)

    ans = []
    for a in range(N):
        for b in edges[a]:
            ans.append((a+1, b+1))

    print(len(ans))
    for a, b in ans:
        print(a, b)

if __name__ == '__main__':
    main() from collections import defaultdict, deque, Counter, OrderedDict from bisect import bisect_left, bisect_right from functools import reduce, lru_cache from heapq import heappush, heappop, heapify import itertools, bisect itertools bisect import math, fractions math fractions import sys, copy sys copy def L(): return sys.stdin.readline().split() L def I(): return int(sys.stdin.readline().rstrip()) I def SL(): return list(sys.stdin.readline().rstrip()) SL int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x def LI(): return [int(x) for x in sys.stdin.readline().split()] LI int(x) - 1 for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) - 1 int(x) int x 1 def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()] LI1 list(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() list(x) list x def LS(): return [list(x) for x in sys.stdin.readline().split()] LS I() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) I() I def IR(n): return [I() for _ in range(n)] IR n n LI() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) LI() LI def LIR(n): return [LI() for _ in range(n)] LIR n n LI1() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) LI1() LI1 def LIR1(n): return [LI1() for _ in range(n)] LIR1 n n SL() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) SL() SL def SR(n): return [SL() for _ in range(n)] SR n n LS() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) LS() LS def LSR(n): return [LS() for _ in range(n)] LSR n n L() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) L() L def LR(n): return [L() for _ in range(n)] LR n n def perm(n, r): return math.factorial(n) // math.factorial(r) perm n n r r def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r)) comb n n r r alphabets = "abcdefghijklmnopqrstuvwxyz" alphabets "abcdefghijklmnopqrstuvwxyz" ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ALPHABETS "ABCDEFGHIJKLMNOPQRSTUVWXYZ" sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 dire = [[1, 0], [0, 1], [-1, 0], [0, -1]] dire [[1, 0], [0, 1], [-1, 0], [0, -1]] [1, 0] 1 0 [0, 1] 0 1 [-1, 0] -1 0 [0, -1] 0 -1 dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]] dire8 [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]] [1, 0] 1 0 [1, 1] 1 1 [0, 1] 0 1 [-1, 1] -1 1 [-1, 0] -1 0 [-1, -1] -1 -1 [0, -1] 0 -1 [1, -1] 1 -1 MOD = 1000000007 MOD 1000000007 INF = float("inf") INF float("inf") float "inf" def main():
    N, K = LI()

    if (N == 2 and K == 0):
        print(1)
        print(1, 2)
        return

    if ((N-1 < 2) or comb(N-1, 2) < K):
        print(-1)
        return
    maxpairs = comb(N-1, 2)

    edges = [[] for _ in range(N)]
    edges[0] = list(range(1, N))

    pairs = list(itertools.combinations(range(1, N), 2))

    for _ in range(maxpairs - K):
        a, b = pairs.pop()
        edges[a].append(b)

    ans = []
    for a in range(N):
        for b in edges[a]:
            ans.append((a+1, b+1))

    print(len(ans))
    for a, b in ans:
        print(a, b) main N, K = LI() N LI() LI K if (N == 2 and K == 0):
        print(1)
        print(1, 2)
        return

     N == 2 and K == 0 N == 2 N 2 K == 0 K 0 print(1) print 1 print(1, 2) print 1 2 return if ((N-1 < 2) or comb(N-1, 2) < K):
        print(-1)
        return
     (N-1 < 2) or comb(N-1, 2) < K N-1 < 2 N-1 N 1 2 comb(N-1, 2) < K comb(N-1, 2) comb N-1 N 1 2 K print(-1) print -1 return maxpairs = comb(N-1, 2) maxpairs comb(N-1, 2) comb N-1 N 1 2 [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] edges = [[] for _ in range(N)] edges [[] for _ in range(N)] edges[0] = list(range(1, N)) edges[0] edges 0 list(range(1, N)) list range(1, N) range 1 N pairs = list(itertools.combinations(range(1, N), 2)) pairs 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 for _ in range(maxpairs - K):
        a, b = pairs.pop()
        edges[a].append(b)

     _ range(maxpairs - K) range maxpairs - K maxpairs K a, b = pairs.pop() a pairs.pop() pairs.pop pairs pop b edges[a].append(b) [a].append [a] edges a append b ans = [] ans [] for a in range(N):
        for b in edges[a]:
            ans.append((a+1, b+1))

     a range(N) range N for b in edges[a]:
            ans.append((a+1, b+1))

     b edges[a] edges a ans.append((a+1, b+1)) ans.append ans append (a+1, b+1) a+1 a 1 b+1 b 1 print(len(ans)) print len(ans) len ans for a, b in ans:
        print(a, b) a b ans print(a, b) print a b if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def LIR1(n): return [LI1() for _ in range(n)] def LIR1(n): return [LI1() for _ in range(n)] LIR1 def SR(n): return [SL() for _ in range(n)] def SR(n): return [SL() for _ in range(n)] SR dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]] [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]] dire8 def perm(n, r): return math.factorial(n) // math.factorial(r) def perm(n, r): return math.factorial(n) // math.factorial(r) perm def L(): return sys.stdin.readline().split() def L(): return sys.stdin.readline().split() L def IR(n): return [I() for _ in range(n)] def IR(n): return [I() for _ in range(n)] IR def LR(n): return [L() for _ in range(n)] def LR(n): return [L() for _ in range(n)] LR dire = [[1, 0], [0, 1], [-1, 0], [0, -1]] [[1, 0], [0, 1], [-1, 0], [0, -1]] dire def LS(): return [list(x) for x in sys.stdin.readline().split()] def LS(): return [list(x) for x in sys.stdin.readline().split()] LS def LSR(n): return [LS() for _ in range(n)] def LSR(n): return [LS() for _ in range(n)] LSR def SL(): return list(sys.stdin.readline().rstrip()) def SL(): return list(sys.stdin.readline().rstrip()) SL def I(): return int(sys.stdin.readline().rstrip()) def I(): return int(sys.stdin.readline().rstrip()) I alphabets = "abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz" alphabets ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ALPHABETS def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()] LI1 def main():
    N, K = LI()

    if (N == 2 and K == 0):
        print(1)
        print(1, 2)
        return

    if ((N-1 < 2) or comb(N-1, 2) < K):
        print(-1)
        return
    maxpairs = comb(N-1, 2)

    edges = [[] for _ in range(N)]
    edges[0] = list(range(1, N))

    pairs = list(itertools.combinations(range(1, N), 2))

    for _ in range(maxpairs - K):
        a, b = pairs.pop()
        edges[a].append(b)

    ans = []
    for a in range(N):
        for b in edges[a]:
            ans.append((a+1, b+1))

    print(len(ans))
    for a, b in ans:
        print(a, b) def main():
    N, K = LI()

    if (N == 2 and K == 0):
        print(1)
        print(1, 2)
        return

    if ((N-1 < 2) or comb(N-1, 2) < K):
        print(-1)
        return
    maxpairs = comb(N-1, 2)

    edges = [[] for _ in range(N)]
    edges[0] = list(range(1, N))

    pairs = list(itertools.combinations(range(1, N), 2))

    for _ in range(maxpairs - K):
        a, b = pairs.pop()
        edges[a].append(b)

    ans = []
    for a in range(N):
        for b in edges[a]:
            ans.append((a+1, b+1))

    print(len(ans))
    for a, b in ans:
        print(a, b) main def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI(): return [int(x) for x in sys.stdin.readline().split()] LI MOD = 1000000007 1000000007 MOD def LIR(n): return [LI() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] LIR INF = float("inf") float("inf") INF def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r)) def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r)) comb
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
INF = float("inf")

def main():
    N, K = LI()

    if (N == 2 and K == 0):
        print(1)
        print(1, 2)
        return

    if ((N-1 < 2) or comb(N-1, 2) < K):
        print(-1)
        return
    maxpairs = comb(N-1, 2)

    edges = [[] for _ in range(N)]
    edges[0] = list(range(1, N))

    pairs = list(itertools.combinations(range(1, N), 2))

    for _ in range(maxpairs - K):
        a, b = pairs.pop()
        edges[a].append(b)

    ans = []
    for a in range(N):
        for b in edges[a]:
            ans.append((a+1, b+1))

    print(len(ans))
    for a, b in ans:
        print(a, b)

if __name__ == '__main__':
    main()