# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    n, k = map(int, input().split())
    val = (n-1)*(n-2)//2
    if k > val:
        print(-1)
    else:
        rem = val-k
        print(n-1+rem)
        for i in range(2,n+1):
            print(1,i)
        a, b = 2, 3
        cnt = 0
        for i in range(rem):
            print(a,b)
            if b < n:
                b+=1
            else:
                a += 1
                b = a+1



resolve() import sys sys sys.setrecursionlimit(10 ** 5 + 10) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 + 10 10 ** 5 10 5 10 def input(): return sys.stdin.readline().strip() input def resolve():

    n, k = map(int, input().split())
    val = (n-1)*(n-2)//2
    if k > val:
        print(-1)
    else:
        rem = val-k
        print(n-1+rem)
        for i in range(2,n+1):
            print(1,i)
        a, b = 2, 3
        cnt = 0
        for i in range(rem):
            print(a,b)
            if b < n:
                b+=1
            else:
                a += 1
                b = a+1 resolve n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k val = (n-1)*(n-2)//2 val (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 if k > val:
        print(-1)
    else:
        rem = val-k
        print(n-1+rem)
        for i in range(2,n+1):
            print(1,i)
        a, b = 2, 3
        cnt = 0
        for i in range(rem):
            print(a,b)
            if b < n:
                b+=1
            else:
                a += 1
                b = a+1 k > val k val print(-1) print -1 rem = val-k rem val-k val k print(n-1+rem) print n-1+rem n-1 n 1 rem 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 a, b = 2, 3 a 2 b 3 cnt = 0 cnt 0 for i in range(rem):
            print(a,b)
            if b < n:
                b+=1
            else:
                a += 1
                b = a+1 i range(rem) range rem print(a,b) print a b if b < n:
                b+=1
            else:
                a += 1
                b = a+1 b < n b n b+=1 b 1 a += 1 a 1 b = a+1 b a+1 a 1 resolve() resolve def resolve():

    n, k = map(int, input().split())
    val = (n-1)*(n-2)//2
    if k > val:
        print(-1)
    else:
        rem = val-k
        print(n-1+rem)
        for i in range(2,n+1):
            print(1,i)
        a, b = 2, 3
        cnt = 0
        for i in range(rem):
            print(a,b)
            if b < n:
                b+=1
            else:
                a += 1
                b = a+1 def resolve():

    n, k = map(int, input().split())
    val = (n-1)*(n-2)//2
    if k > val:
        print(-1)
    else:
        rem = val-k
        print(n-1+rem)
        for i in range(2,n+1):
            print(1,i)
        a, b = 2, 3
        cnt = 0
        for i in range(rem):
            print(a,b)
            if b < n:
                b+=1
            else:
                a += 1
                b = a+1 resolve def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    n, k = map(int, input().split())
    val = (n-1)*(n-2)//2
    if k > val:
        print(-1)
    else:
        rem = val-k
        print(n-1+rem)
        for i in range(2,n+1):
            print(1,i)
        a, b = 2, 3
        cnt = 0
        for i in range(rem):
            print(a,b)
            if b < n:
                b+=1
            else:
                a += 1
                b = a+1



resolve()
