def examA():
    S = SI()
    ans = "Good"
    for i in range(len(S)-1):
        if S[i+1]==S[i]:
            ans = "Bad"
    print(ans)
    return

def examB():
    N, L = LI()
    ans = 0
    if L>=0:
        for i in range(N - 1):
            ans += (L + i + 1)
    else:
        for i in range(N):
            ans += (L+i)
        if L+N-1<0:
            ans -=(L+N-1)
    print(ans)
    return

def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x
def lcm(x, y):
    return x * y // gcd(x, y)
def examC():
    A, B, C, D = LI()
    CD = lcm(C,D)
    ans = B - (B//C + B//D - B//CD) - ((A-1) - ((A-1)//C + (A-1)//D - (A-1)//CD))
    print(ans)
    return

def examD():
    N = I()
    AB = [LI() for _ in range(N)]
    AB.sort(key=lambda x:x[1])
    cur = 0; ans = "Yes"
    for a,b in AB:
        cur +=a
        if b<cur:
            ans = "No"
            break
    print(ans)
    return

def examE():
    N, K = LI()
    maxK = (N-1)*(N-2)//2
    if K>maxK:
        print(-1)
        exit()
    ansC = []
    for i in range(1,N):
        ansC.append([1,i+1])
    k = maxK-K
    for i in range(1, N):
        if k == 0:
            break
        for j in range(i + 1, N):
            ansC.append([i+1, j+1])
            k -= 1
            if k == 0:
                break
    M = len(ansC)
    print(M)
    for v in ansC:
        print(" ".join(map(str,v)))
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examE() def examA():
    S = SI()
    ans = "Good"
    for i in range(len(S)-1):
        if S[i+1]==S[i]:
            ans = "Bad"
    print(ans)
    return examA S = SI() S SI() SI ans = "Good" ans "Good" for i in range(len(S)-1):
        if S[i+1]==S[i]:
            ans = "Bad"
     i range(len(S)-1) range len(S)-1 len(S) len S 1 if S[i+1]==S[i]:
            ans = "Bad"
     S[i+1]==S[i] S[i+1] S i+1 i 1 S[i] S i ans = "Bad" ans "Bad" print(ans) print ans return def examB():
    N, L = LI()
    ans = 0
    if L>=0:
        for i in range(N - 1):
            ans += (L + i + 1)
    else:
        for i in range(N):
            ans += (L+i)
        if L+N-1<0:
            ans -=(L+N-1)
    print(ans)
    return examB N, L = LI() N LI() LI L ans = 0 ans 0 if L>=0:
        for i in range(N - 1):
            ans += (L + i + 1)
    else:
        for i in range(N):
            ans += (L+i)
        if L+N-1<0:
            ans -=(L+N-1)
     L>=0 L 0 for i in range(N - 1):
            ans += (L + i + 1)
     i range(N - 1) range N - 1 N 1 ans += (L + i + 1) ans L + i + 1 L + i L i 1 for i in range(N):
            ans += (L+i)
         i range(N) range N ans += (L+i) ans L+i L i if L+N-1<0:
            ans -=(L+N-1)
     L+N-1<0 L+N-1 L+N L N 1 0 ans -=(L+N-1) ans L+N-1 L+N L N 1 print(ans) print ans return def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x gcd if y == 0:
        return x
     y == 0 y 0 return x x while y != 0:
        x, y = y, x % y
     y != 0 y 0 x, y = y, x % y x y y x % y x y return x x x x y y def lcm(x, y):
    return x * y // gcd(x, y) lcm return x * y // gcd(x, y) x * y // gcd(x, y) x * y x y gcd(x, y) gcd x y x x y y def examC():
    A, B, C, D = LI()
    CD = lcm(C,D)
    ans = B - (B//C + B//D - B//CD) - ((A-1) - ((A-1)//C + (A-1)//D - (A-1)//CD))
    print(ans)
    return examC A, B, C, D = LI() A LI() LI B C D CD = lcm(C,D) CD lcm(C,D) lcm C D ans = B - (B//C + B//D - B//CD) - ((A-1) - ((A-1)//C + (A-1)//D - (A-1)//CD)) ans B - (B//C + B//D - B//CD) - ((A-1) - ((A-1)//C + (A-1)//D - (A-1)//CD)) B - (B//C + B//D - B//CD) B B//C + B//D - B//CD B//C + B//D B//C B C B//D B D B//CD B CD (A-1) - ((A-1)//C + (A-1)//D - (A-1)//CD) A-1 A 1 (A-1)//C + (A-1)//D - (A-1)//CD (A-1)//C + (A-1)//D (A-1)//C A-1 A 1 C (A-1)//D A-1 A 1 D (A-1)//CD A-1 A 1 CD print(ans) print ans return def examD():
    N = I()
    AB = [LI() for _ in range(N)]
    AB.sort(key=lambda x:x[1])
    cur = 0; ans = "Yes"
    for a,b in AB:
        cur +=a
        if b<cur:
            ans = "No"
            break
    print(ans)
    return examD N = I() N I() I LI() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) LI() LI AB = [LI() for _ in range(N)] AB [LI() for _ in range(N)] AB.sort(key=lambda x:x[1]) AB.sort AB sort key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x cur = 0 cur 0 ans = "Yes" ans "Yes" for a,b in AB:
        cur +=a
        if b<cur:
            ans = "No"
            break
     a b AB cur +=a cur a if b<cur:
            ans = "No"
            break
     b<cur b cur ans = "No" ans "No" break print(ans) print ans return def examE():
    N, K = LI()
    maxK = (N-1)*(N-2)//2
    if K>maxK:
        print(-1)
        exit()
    ansC = []
    for i in range(1,N):
        ansC.append([1,i+1])
    k = maxK-K
    for i in range(1, N):
        if k == 0:
            break
        for j in range(i + 1, N):
            ansC.append([i+1, j+1])
            k -= 1
            if k == 0:
                break
    M = len(ansC)
    print(M)
    for v in ansC:
        print(" ".join(map(str,v)))
    return examE N, K = LI() N LI() LI K maxK = (N-1)*(N-2)//2 maxK (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 if K>maxK:
        print(-1)
        exit()
     K>maxK K maxK print(-1) print -1 exit() exit ansC = [] ansC [] for i in range(1,N):
        ansC.append([1,i+1])
     i range(1,N) range 1 N ansC.append([1,i+1]) ansC.append ansC append [1,i+1] 1 i+1 i 1 k = maxK-K k maxK-K maxK K for i in range(1, N):
        if k == 0:
            break
        for j in range(i + 1, N):
            ansC.append([i+1, j+1])
            k -= 1
            if k == 0:
                break
     i range(1, N) range 1 N if k == 0:
            break
         k == 0 k 0 break for j in range(i + 1, N):
            ansC.append([i+1, j+1])
            k -= 1
            if k == 0:
                break
     j range(i + 1, N) range i + 1 i 1 N ansC.append([i+1, j+1]) ansC.append ansC append [i+1, j+1] i+1 i 1 j+1 j 1 k -= 1 k 1 if k == 0:
                break
     k == 0 k 0 break M = len(ansC) M len(ansC) len ansC print(M) print M for v in ansC:
        print(" ".join(map(str,v)))
     v ansC print(" ".join(map(str,v))) print " ".join(map(str,v)) " ".join " " join map(str,v) map str v return import sys,copy,bisect,itertools,heapq,math sys copy bisect itertools heapq math from heapq import heappop,heappush,heapify from collections import Counter,defaultdict,deque def I(): return int(sys.stdin.readline()) I def LI(): return list(map(int,sys.stdin.readline().split())) LI def LSI(): return list(map(str,sys.stdin.readline().split())) LSI def LS(): return sys.stdin.readline().split() LS def SI(): return sys.stdin.readline().strip() SI mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 inf = float('inf') inf float('inf') float 'inf' if __name__ == '__main__':
    examE() __name__ == '__main__' __name__ '__main__' examE() examE def LI(): return list(map(int,sys.stdin.readline().split())) def LI(): return list(map(int,sys.stdin.readline().split())) LI def LS(): return sys.stdin.readline().split() def LS(): return sys.stdin.readline().split() LS def I(): return int(sys.stdin.readline()) def I(): return int(sys.stdin.readline()) I def SI(): return sys.stdin.readline().strip() def SI(): return sys.stdin.readline().strip() SI def examE():
    N, K = LI()
    maxK = (N-1)*(N-2)//2
    if K>maxK:
        print(-1)
        exit()
    ansC = []
    for i in range(1,N):
        ansC.append([1,i+1])
    k = maxK-K
    for i in range(1, N):
        if k == 0:
            break
        for j in range(i + 1, N):
            ansC.append([i+1, j+1])
            k -= 1
            if k == 0:
                break
    M = len(ansC)
    print(M)
    for v in ansC:
        print(" ".join(map(str,v)))
    return def examE():
    N, K = LI()
    maxK = (N-1)*(N-2)//2
    if K>maxK:
        print(-1)
        exit()
    ansC = []
    for i in range(1,N):
        ansC.append([1,i+1])
    k = maxK-K
    for i in range(1, N):
        if k == 0:
            break
        for j in range(i + 1, N):
            ansC.append([i+1, j+1])
            k -= 1
            if k == 0:
                break
    M = len(ansC)
    print(M)
    for v in ansC:
        print(" ".join(map(str,v)))
    return examE def examA():
    S = SI()
    ans = "Good"
    for i in range(len(S)-1):
        if S[i+1]==S[i]:
            ans = "Bad"
    print(ans)
    return def examA():
    S = SI()
    ans = "Good"
    for i in range(len(S)-1):
        if S[i+1]==S[i]:
            ans = "Bad"
    print(ans)
    return examA def lcm(x, y):
    return x * y // gcd(x, y) def lcm(x, y):
    return x * y // gcd(x, y) lcm def examB():
    N, L = LI()
    ans = 0
    if L>=0:
        for i in range(N - 1):
            ans += (L + i + 1)
    else:
        for i in range(N):
            ans += (L+i)
        if L+N-1<0:
            ans -=(L+N-1)
    print(ans)
    return def examB():
    N, L = LI()
    ans = 0
    if L>=0:
        for i in range(N - 1):
            ans += (L + i + 1)
    else:
        for i in range(N):
            ans += (L+i)
        if L+N-1<0:
            ans -=(L+N-1)
    print(ans)
    return examB def examC():
    A, B, C, D = LI()
    CD = lcm(C,D)
    ans = B - (B//C + B//D - B//CD) - ((A-1) - ((A-1)//C + (A-1)//D - (A-1)//CD))
    print(ans)
    return def examC():
    A, B, C, D = LI()
    CD = lcm(C,D)
    ans = B - (B//C + B//D - B//CD) - ((A-1) - ((A-1)//C + (A-1)//D - (A-1)//CD))
    print(ans)
    return examC def LSI(): return list(map(str,sys.stdin.readline().split())) def LSI(): return list(map(str,sys.stdin.readline().split())) LSI def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x gcd mod = 10**9 + 7 10**9 + 7 mod inf = float('inf') float('inf') inf def examD():
    N = I()
    AB = [LI() for _ in range(N)]
    AB.sort(key=lambda x:x[1])
    cur = 0; ans = "Yes"
    for a,b in AB:
        cur +=a
        if b<cur:
            ans = "No"
            break
    print(ans)
    return def examD():
    N = I()
    AB = [LI() for _ in range(N)]
    AB.sort(key=lambda x:x[1])
    cur = 0; ans = "Yes"
    for a,b in AB:
        cur +=a
        if b<cur:
            ans = "No"
            break
    print(ans)
    return examD
def examA():
    S = SI()
    ans = "Good"
    for i in range(len(S)-1):
        if S[i+1]==S[i]:
            ans = "Bad"
    print(ans)
    return

def examB():
    N, L = LI()
    ans = 0
    if L>=0:
        for i in range(N - 1):
            ans += (L + i + 1)
    else:
        for i in range(N):
            ans += (L+i)
        if L+N-1<0:
            ans -=(L+N-1)
    print(ans)
    return

def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x
def lcm(x, y):
    return x * y // gcd(x, y)
def examC():
    A, B, C, D = LI()
    CD = lcm(C,D)
    ans = B - (B//C + B//D - B//CD) - ((A-1) - ((A-1)//C + (A-1)//D - (A-1)//CD))
    print(ans)
    return

def examD():
    N = I()
    AB = [LI() for _ in range(N)]
    AB.sort(key=lambda x:x[1])
    cur = 0; ans = "Yes"
    for a,b in AB:
        cur +=a
        if b<cur:
            ans = "No"
            break
    print(ans)
    return

def examE():
    N, K = LI()
    maxK = (N-1)*(N-2)//2
    if K>maxK:
        print(-1)
        exit()
    ansC = []
    for i in range(1,N):
        ansC.append([1,i+1])
    k = maxK-K
    for i in range(1, N):
        if k == 0:
            break
        for j in range(i + 1, N):
            ansC.append([i+1, j+1])
            k -= 1
            if k == 0:
                break
    M = len(ansC)
    print(M)
    for v in ansC:
        print(" ".join(map(str,v)))
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examE()
