import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    if K>(N-2)*(N-1)//2:
        print(-1)
        return 
    s=set()
    cur=0
    f=0
    for i in range(1,N):
        for j in range(i+1,N):
            if cur<K:
                s.add((i,j))
                cur+=1
            else:
                f=1
            if f:
                break
        if f:
            break
    print(N*(N-1)//2-K)
    for i in range(0,N):
        for j in range(i+1,N):
            if (i,j) not in s:
                print(i+1,j+1)





if __name__ == "__main__":
    main() import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 import math math from copy import copy, deepcopy from copy import deepcopy as dcp from operator import itemgetter from bisect import bisect_left, bisect, bisect_right from collections import deque, defaultdict from collections import Counter from itertools import accumulate,combinations,permutations,product from heapq import heapify,heappop,heappush from functools import reduce,lru_cache from decimal import Decimal def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x input x=sys.stdin.readline() x sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline return x[:-1] if x[-1]=="\n" else x x[:-1] if x[-1]=="\n" else x x[-1]=="\n" x[-1] x -1 "\n" x[:-1] x :-1 -1 x def printe(*x):print("## ",*x,file=sys.stderr) printe *x def printl(li): _=print(*li, sep="\n") if li else None printl li li def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds argsort inds=sorted(range(len(s)), key=lambda k: s[k]) inds sorted(range(len(s)), key=lambda k: s[k]) sorted range(len(s)) range len(s) len s key=lambda k: s[k] key lambda k: s[k] s[k] s k k s[i] for i in inds for i in inds i inds for i in inds s[i] s i if return_sorted: return inds, [s[i] for i in inds]
     return_sorted return inds inds s s return_sorted=False return_sorted False def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65 alp2num c c cap=False cap False def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65) num2alp i i cap=False cap False def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)] matmat K,N,M=len(B),len(A),len(B[0]) K len(B) len B N len(A) len A M len(B[0]) len B[0] B 0 [sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N) for i in range(N) i range(N) range N for i in range(N) [sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)] [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)] A A B B def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)] matvec N,size=len(v),len(M) N len(v) len v size len(M) len M sum([M[i][j]*v[j] for j in range(N)]) for i in range(size) for i in range(size) i range(size) range size for i in range(size) sum([M[i][j]*v[j] for j in range(N)]) sum [M[i][j]*v[j] for j in range(N)] return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)] [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)] M M v v def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)] T n,m=len(M),len(M[0]) n len(M) len M m len(M[0]) len M[0] M 0 [M[j][i] for j in range(n)] for i in range(m) for i in range(m) i range(m) range m for i in range(m) [M[j][i] for j in range(n)] return [[M[j][i] for j in range(n)] for i in range(m)] [[M[j][i] for j in range(n)] for i in range(m)] M M def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    if K>(N-2)*(N-1)//2:
        print(-1)
        return 
    s=set()
    cur=0
    f=0
    for i in range(1,N):
        for j in range(i+1,N):
            if cur<K:
                s.add((i,j))
                cur+=1
            else:
                f=1
            if f:
                break
        if f:
            break
    print(N*(N-1)//2-K)
    for i in range(0,N):
        for j in range(i+1,N):
            if (i,j) not in s:
                print(i+1,j+1) main mod = 1000000007 mod 1000000007 N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K if K>(N-2)*(N-1)//2:
        print(-1)
        return 
     K>(N-2)*(N-1)//2 K (N-2)*(N-1)//2 (N-2)*(N-1) N-2 N 2 N-1 N 1 2 print(-1) print -1 return s=set() s set() set cur=0 cur 0 f=0 f 0 for i in range(1,N):
        for j in range(i+1,N):
            if cur<K:
                s.add((i,j))
                cur+=1
            else:
                f=1
            if f:
                break
        if f:
            break
     i range(1,N) range 1 N for j in range(i+1,N):
            if cur<K:
                s.add((i,j))
                cur+=1
            else:
                f=1
            if f:
                break
         j range(i+1,N) range i+1 i 1 N if cur<K:
                s.add((i,j))
                cur+=1
            else:
                f=1
             cur<K cur K s.add((i,j)) s.add s add (i,j) i j cur+=1 cur 1 f=1 f 1 if f:
                break
         f break if f:
            break
     f break print(N*(N-1)//2-K) print N*(N-1)//2-K N*(N-1)//2 N*(N-1) N N-1 N 1 2 K for i in range(0,N):
        for j in range(i+1,N):
            if (i,j) not in s:
                print(i+1,j+1) i range(0,N) range 0 N for j in range(i+1,N):
            if (i,j) not in s:
                print(i+1,j+1) j range(i+1,N) range i+1 i 1 N if (i,j) not in s:
                print(i+1,j+1) (i,j) not in s (i,j) i j s print(i+1,j+1) print i+1 i 1 j+1 j 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    if K>(N-2)*(N-1)//2:
        print(-1)
        return 
    s=set()
    cur=0
    f=0
    for i in range(1,N):
        for j in range(i+1,N):
            if cur<K:
                s.add((i,j))
                cur+=1
            else:
                f=1
            if f:
                break
        if f:
            break
    print(N*(N-1)//2-K)
    for i in range(0,N):
        for j in range(i+1,N):
            if (i,j) not in s:
                print(i+1,j+1) def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    if K>(N-2)*(N-1)//2:
        print(-1)
        return 
    s=set()
    cur=0
    f=0
    for i in range(1,N):
        for j in range(i+1,N):
            if cur<K:
                s.add((i,j))
                cur+=1
            else:
                f=1
            if f:
                break
        if f:
            break
    print(N*(N-1)//2-K)
    for i in range(0,N):
        for j in range(i+1,N):
            if (i,j) not in s:
                print(i+1,j+1) main def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65) def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65) num2alp def printe(*x):print("## ",*x,file=sys.stderr) def printe(*x):print("## ",*x,file=sys.stderr) printe def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x input def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)] def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)] matmat def printl(li): _=print(*li, sep="\n") if li else None def printl(li): _=print(*li, sep="\n") if li else None printl def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65 def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65 alp2num def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)] def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)] matvec def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)] def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)] T def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds argsort
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    if K>(N-2)*(N-1)//2:
        print(-1)
        return 
    s=set()
    cur=0
    f=0
    for i in range(1,N):
        for j in range(i+1,N):
            if cur<K:
                s.add((i,j))
                cur+=1
            else:
                f=1
            if f:
                break
        if f:
            break
    print(N*(N-1)//2-K)
    for i in range(0,N):
        for j in range(i+1,N):
            if (i,j) not in s:
                print(i+1,j+1)





if __name__ == "__main__":
    main()