import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
n,k=MI()
if k>((n-1)*(n-2))//2:
    print(-1)
else:
    count=0
    m=((n-1)*n)//2-k
    print(m)
    for i in range(n-1):
        for j in range(i+1,n):
            print(i+1,j+1)
            count+=1
            if count==m:
                sys.exit() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil from operator import itemgetter def I(): return int(input()) I def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) LI int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input def LI2(): return [int(input()) for i in range(n)] LI2 [LI()]for i in range(n) for i in range(n) i range(n) range n for i in range(n) [LI()] LI() LI def MXI(): return [[LI()]for i in range(n)] MXI def printns(x): print('\n'.join(x)) printns x x def printni(x): print('\n'.join(list(map(str,x)))) printni x x inf = 10**17 inf 10**17 10 17 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 n,k=MI() n MI() MI k if k>((n-1)*(n-2))//2:
    print(-1)
else:
    count=0
    m=((n-1)*n)//2-k
    print(m)
    for i in range(n-1):
        for j in range(i+1,n):
            print(i+1,j+1)
            count+=1
            if count==m:
                sys.exit() 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 count=0 count 0 m=((n-1)*n)//2-k m ((n-1)*n)//2-k ((n-1)*n)//2 (n-1)*n n-1 n 1 n 2 k print(m) print m for i in range(n-1):
        for j in range(i+1,n):
            print(i+1,j+1)
            count+=1
            if count==m:
                sys.exit() i range(n-1) range n-1 n 1 for j in range(i+1,n):
            print(i+1,j+1)
            count+=1
            if count==m:
                sys.exit() j range(i+1,n) range i+1 i 1 n print(i+1,j+1) print i+1 i 1 j+1 j 1 count+=1 count 1 if count==m:
                sys.exit() count==m count m sys.exit() sys.exit sys exit def MXI(): return [[LI()]for i in range(n)] def MXI(): return [[LI()]for i in range(n)] MXI count+=1 1 count def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI m=((n-1)*n)//2-k ((n-1)*n)//2-k m def printni(x): print('\n'.join(list(map(str,x)))) def printni(x): print('\n'.join(list(map(str,x)))) printni def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI def LI2(): return [int(input()) for i in range(n)] def LI2(): return [int(input()) for i in range(n)] LI2 def printns(x): print('\n'.join(x)) def printns(x): print('\n'.join(x)) printns inf = 10**17 10**17 inf count=0 0 count n,k=MI() MI() n def I(): return int(input()) def I(): return int(input()) I mod = 10**9 + 7 10**9 + 7 mod k=MI() MI() k input = sys.stdin.readline sys.stdin.readline input
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
n,k=MI()
if k>((n-1)*(n-2))//2:
    print(-1)
else:
    count=0
    m=((n-1)*n)//2-k
    print(m)
    for i in range(n-1):
        for j in range(i+1,n):
            print(i+1,j+1)
            count+=1
            if count==m:
                sys.exit()