import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    ans = []

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

    for i in range(n - 1):
        ans.append([i, n - 1])

    breakflg = False
    for i in range(n - 1):
        for j in range(i + 1, n - 1):
            if tmp == k:
                breakflg = True
                break

            tmp -= 1
            ans.append([i, j])

        if breakflg:
            break

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


if __name__ == '__main__':
    main() import sys sys import re re import math math import collections collections import bisect bisect import itertools itertools import fractions fractions import functools functools import copy copy import heapq heapq import decimal decimal import statistics statistics import queue queue sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 10 ** 16 INF 10 ** 16 10 16 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 ni = lambda: int(sys.stdin.readline()) ni lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline ns = lambda: map(int, sys.stdin.readline().split()) ns lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split na = lambda: list(map(int, sys.stdin.readline().split())) na lambda: list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) nb lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) list map(lambda x: int(x) - 1, sys.stdin.readline().split()) map lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split def main():
    n, k = ns()
    ans = []

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

    for i in range(n - 1):
        ans.append([i, n - 1])

    breakflg = False
    for i in range(n - 1):
        for j in range(i + 1, n - 1):
            if tmp == k:
                breakflg = True
                break

            tmp -= 1
            ans.append([i, j])

        if breakflg:
            break

    print(len(ans))
    for a, b in ans:
        print(a + 1, b + 1) main n, k = ns() n ns() ns k ans = [] ans [] tmp = (n - 1) * (n - 2) // 2 tmp (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 if k > tmp:
        print(-1)
        exit(0)

     k > tmp k tmp print(-1) print -1 exit(0) exit 0 for i in range(n - 1):
        ans.append([i, n - 1])

     i range(n - 1) range n - 1 n 1 ans.append([i, n - 1]) ans.append ans append [i, n - 1] i n - 1 n 1 breakflg = False breakflg False for i in range(n - 1):
        for j in range(i + 1, n - 1):
            if tmp == k:
                breakflg = True
                break

            tmp -= 1
            ans.append([i, j])

        if breakflg:
            break

     i range(n - 1) range n - 1 n 1 for j in range(i + 1, n - 1):
            if tmp == k:
                breakflg = True
                break

            tmp -= 1
            ans.append([i, j])

         j range(i + 1, n - 1) range i + 1 i 1 n - 1 n 1 if tmp == k:
                breakflg = True
                break

             tmp == k tmp k breakflg = True breakflg True break tmp -= 1 tmp 1 ans.append([i, j]) ans.append ans append [i, j] i j if breakflg:
            break

     breakflg break print(len(ans)) print len(ans) len ans for a, b in ans:
        print(a + 1, b + 1) a b ans print(a + 1, b + 1) print a + 1 a 1 b + 1 b 1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main na = lambda: list(map(int, sys.stdin.readline().split())) lambda: list(map(int, sys.stdin.readline().split())) na INF = 10 ** 16 10 ** 16 INF MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) nb def main():
    n, k = ns()
    ans = []

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

    for i in range(n - 1):
        ans.append([i, n - 1])

    breakflg = False
    for i in range(n - 1):
        for j in range(i + 1, n - 1):
            if tmp == k:
                breakflg = True
                break

            tmp -= 1
            ans.append([i, j])

        if breakflg:
            break

    print(len(ans))
    for a, b in ans:
        print(a + 1, b + 1) def main():
    n, k = ns()
    ans = []

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

    for i in range(n - 1):
        ans.append([i, n - 1])

    breakflg = False
    for i in range(n - 1):
        for j in range(i + 1, n - 1):
            if tmp == k:
                breakflg = True
                break

            tmp -= 1
            ans.append([i, j])

        if breakflg:
            break

    print(len(ans))
    for a, b in ans:
        print(a + 1, b + 1) main ni = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) ni ns = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) ns
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    ans = []

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

    for i in range(n - 1):
        ans.append([i, n - 1])

    breakflg = False
    for i in range(n - 1):
        for j in range(i + 1, n - 1):
            if tmp == k:
                breakflg = True
                break

            tmp -= 1
            ans.append([i, j])

        if breakflg:
            break

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


if __name__ == '__main__':
    main()
