from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(10 ** 9)



INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, k = LI()
if k > (n - 1) * (n - 2) // 2:
    print(-1)
    exit(0)


ans = []
for i in range(2, n + 1):
    ans += [(1, i)]
ans += list(combinations(range(2, n + 1), 2))[:(n - 1) * (n - 2) // 2 - k]
print(len(ans))
for j in ans:
    print(*j)
 from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math math import bisect bisect import random random from itertools import permutations, accumulate, combinations, product import sys sys import string string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor from operator import mul from functools import reduce sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 10 ** 20 INF 10 ** 20 10 20 def LI(): return list(map(int, sys.stdin.buffer.readline().split())) LI def I(): return int(sys.stdin.buffer.readline()) I def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() LS def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') S I() for i in range(n) for i in range(n) i range(n) range n for i in range(n) I() I def IR(n): return [I() for i in range(n)] IR n n LI() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LI() LI def LIR(n): return [LI() for i in range(n)] LIR n n S() for i in range(n) for i in range(n) i range(n) range n for i in range(n) S() S def SR(n): return [S() for i in range(n)] SR n n LS() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LS() LS def LSR(n): return [LS() for i in range(n)] LSR n n list(S()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) list(S()) list S() S def SRL(n): return [list(S()) for i in range(n)] SRL n n [int(j) for j in list(S())] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [int(j) for j in list(S())] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] MSRL n n mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 n, k = LI() n LI() LI k if k > (n - 1) * (n - 2) // 2:
    print(-1)
    exit(0) 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(0) exit 0 ans = [] ans [] for i in range(2, n + 1):
    ans += [(1, i)] i range(2, n + 1) range 2 n + 1 n 1 ans += [(1, i)] ans [(1, i)] (1, i) 1 i ans += list(combinations(range(2, n + 1), 2))[:(n - 1) * (n - 2) // 2 - k] ans list(combinations(range(2, n + 1), 2))[:(n - 1) * (n - 2) // 2 - k] (combinations(range(2, n + 1), 2)) list combinations(range(2, n + 1), 2) combinations range(2, n + 1) range 2 n + 1 n 1 2 :(n - 1) * (n - 2) // 2 - 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 k print(len(ans)) print len(ans) len ans for j in ans:
    print(*j) j ans print(*j) print *j j mod = 10 ** 9 + 7 10 ** 9 + 7 mod def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) LI ans += [(1, i)] [(1, i)] ans ans = [] [] ans def SR(n): return [S() for i in range(n)] def SR(n): return [S() for i in range(n)] SR n, k = LI() LI() n def IR(n): return [I() for i in range(n)] def IR(n): return [I() for i in range(n)] IR ans += list(combinations(range(2, n + 1), 2))[:(n - 1) * (n - 2) // 2 - k] list(combinations(range(2, n + 1), 2))[:(n - 1) * (n - 2) // 2 - k] ans def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() LS def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') S def SRL(n): return [list(S()) for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] SRL def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] MSRL INF = 10 ** 20 10 ** 20 INF k = LI() LI() k def LIR(n): return [LI() for i in range(n)] def LIR(n): return [LI() for i in range(n)] LIR def I(): return int(sys.stdin.buffer.readline()) def I(): return int(sys.stdin.buffer.readline()) I def LSR(n): return [LS() for i in range(n)] def LSR(n): return [LS() for i in range(n)] LSR
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(10 ** 9)



INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, k = LI()
if k > (n - 1) * (n - 2) // 2:
    print(-1)
    exit(0)


ans = []
for i in range(2, n + 1):
    ans += [(1, i)]
ans += list(combinations(range(2, n + 1), 2))[:(n - 1) * (n - 2) // 2 - k]
print(len(ans))
for j in ans:
    print(*j)

