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


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
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 = 1000000007


def main():
    n, k = LI()
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
        return
    else:
        add_v = (n - 1) * (n - 2) // 2 - k
        print(n - 1 + add_v)
        cnt = 0
        for i in range(2, n + 1):
            print(1, i)
        if cnt == add_v:
            return
        for j in range(2, n + 1):
            for l in range(j + 1, n + 1):
                print(j, l)
                cnt += 1
                if cnt >= add_v:
                    return


main() 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 INF = float('inf') INF float('inf') float 'inf' def LI(): return list(map(int, sys.stdin.readline().split())) LI def I(): return int(sys.stdin.readline()) I def LS(): return sys.stdin.readline().split() LS def S(): return sys.stdin.readline().strip() 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 = 1000000007 mod 1000000007 def main():
    n, k = LI()
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
        return
    else:
        add_v = (n - 1) * (n - 2) // 2 - k
        print(n - 1 + add_v)
        cnt = 0
        for i in range(2, n + 1):
            print(1, i)
        if cnt == add_v:
            return
        for j in range(2, n + 1):
            for l in range(j + 1, n + 1):
                print(j, l)
                cnt += 1
                if cnt >= add_v:
                    return main n, k = LI() n LI() LI k if k > (n - 1) * (n - 2) // 2:
        print(-1)
        return
    else:
        add_v = (n - 1) * (n - 2) // 2 - k
        print(n - 1 + add_v)
        cnt = 0
        for i in range(2, n + 1):
            print(1, i)
        if cnt == add_v:
            return
        for j in range(2, n + 1):
            for l in range(j + 1, n + 1):
                print(j, l)
                cnt += 1
                if cnt >= add_v:
                    return 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 return add_v = (n - 1) * (n - 2) // 2 - k add_v (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(n - 1 + add_v) print n - 1 + add_v n - 1 n 1 add_v cnt = 0 cnt 0 for i in range(2, n + 1):
            print(1, i)
         i range(2, n + 1) range 2 n + 1 n 1 print(1, i) print 1 i if cnt == add_v:
            return
         cnt == add_v cnt add_v return for j in range(2, n + 1):
            for l in range(j + 1, n + 1):
                print(j, l)
                cnt += 1
                if cnt >= add_v:
                    return j range(2, n + 1) range 2 n + 1 n 1 for l in range(j + 1, n + 1):
                print(j, l)
                cnt += 1
                if cnt >= add_v:
                    return l range(j + 1, n + 1) range j + 1 j 1 n + 1 n 1 print(j, l) print j l cnt += 1 cnt 1 if cnt >= add_v:
                    return cnt >= add_v cnt add_v return main() main def IR(n): return [I() for i in range(n)] def IR(n): return [I() for i in range(n)] IR def SRL(n): return [list(S()) for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] SRL INF = float('inf') float('inf') INF def LI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys.stdin.readline().split())) LI def SR(n): return [S() for i in range(n)] def SR(n): return [S() for i in range(n)] SR 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 def LS(): return sys.stdin.readline().split() def LS(): return sys.stdin.readline().split() LS mod = 1000000007 1000000007 mod 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.readline()) def I(): return int(sys.stdin.readline()) I def main():
    n, k = LI()
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
        return
    else:
        add_v = (n - 1) * (n - 2) // 2 - k
        print(n - 1 + add_v)
        cnt = 0
        for i in range(2, n + 1):
            print(1, i)
        if cnt == add_v:
            return
        for j in range(2, n + 1):
            for l in range(j + 1, n + 1):
                print(j, l)
                cnt += 1
                if cnt >= add_v:
                    return def main():
    n, k = LI()
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
        return
    else:
        add_v = (n - 1) * (n - 2) // 2 - k
        print(n - 1 + add_v)
        cnt = 0
        for i in range(2, n + 1):
            print(1, i)
        if cnt == add_v:
            return
        for j in range(2, n + 1):
            for l in range(j + 1, n + 1):
                print(j, l)
                cnt += 1
                if cnt >= add_v:
                    return main def LSR(n): return [LS() for i in range(n)] def LSR(n): return [LS() for i in range(n)] LSR def S(): return sys.stdin.readline().strip() def S(): return sys.stdin.readline().strip() S
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


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
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 = 1000000007


def main():
    n, k = LI()
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
        return
    else:
        add_v = (n - 1) * (n - 2) // 2 - k
        print(n - 1 + add_v)
        cnt = 0
        for i in range(2, n + 1):
            print(1, i)
        if cnt == add_v:
            return
        for j in range(2, n + 1):
            for l in range(j + 1, n + 1):
                print(j, l)
                cnt += 1
                if cnt >= add_v:
                    return


main()