# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,K=map(int,input().split())
    if (N-1)*(N-2)//2<K:
        print(-1)
    else:
        ans=[]
        for i in range(2,N+1):
            ans.append((1,i))
        i,j=2,3
        for _ in range((N-1)*(N-2)//2-K):
            ans.append((i,j))
            j+=1
            if j>N:
                i+=1
                j=i+1
        print(len(ans))
        for a in ans:
            print(*a)

if __name__ == '__main__':
    main() import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 INF=10**18 INF 10**18 10 18 MOD=10**9+7 MOD 10**9+7 10**9 10 9 7 input=lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip YesNo=lambda b: bool([print('Yes')] if b else print('No')) YesNo lambda b: bool([print('Yes')] if b else print('No')) bool([print('Yes')] if b else print('No')) bool [print('Yes')] if b else print('No') b [print('Yes')] print('Yes') print 'Yes' print('No') print 'No' b YESNO=lambda b: bool([print('YES')] if b else print('NO')) YESNO lambda b: bool([print('YES')] if b else print('NO')) bool([print('YES')] if b else print('NO')) bool [print('YES')] if b else print('NO') b [print('YES')] print('YES') print 'YES' print('NO') print 'NO' b int1=lambda x:int(x)-1 int1 lambda x:int(x)-1 int(x)-1 int(x) int x 1 x def main():
    N,K=map(int,input().split())
    if (N-1)*(N-2)//2<K:
        print(-1)
    else:
        ans=[]
        for i in range(2,N+1):
            ans.append((1,i))
        i,j=2,3
        for _ in range((N-1)*(N-2)//2-K):
            ans.append((i,j))
            j+=1
            if j>N:
                i+=1
                j=i+1
        print(len(ans))
        for a in ans:
            print(*a) main N,K=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split K if (N-1)*(N-2)//2<K:
        print(-1)
    else:
        ans=[]
        for i in range(2,N+1):
            ans.append((1,i))
        i,j=2,3
        for _ in range((N-1)*(N-2)//2-K):
            ans.append((i,j))
            j+=1
            if j>N:
                i+=1
                j=i+1
        print(len(ans))
        for a in ans:
            print(*a) (N-1)*(N-2)//2<K (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 K print(-1) print -1 ans=[] ans [] for i in range(2,N+1):
            ans.append((1,i))
         i range(2,N+1) range 2 N+1 N 1 ans.append((1,i)) ans.append ans append (1,i) 1 i i,j=2,3 i 2 j 3 for _ in range((N-1)*(N-2)//2-K):
            ans.append((i,j))
            j+=1
            if j>N:
                i+=1
                j=i+1
         _ range((N-1)*(N-2)//2-K) range (N-1)*(N-2)//2-K (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 K ans.append((i,j)) ans.append ans append (i,j) i j j+=1 j 1 if j>N:
                i+=1
                j=i+1
         j>N j N i+=1 i 1 j=i+1 j i+1 i 1 print(len(ans)) print len(ans) len ans for a in ans:
            print(*a) a ans print(*a) print *a a if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main INF=10**18 10**18 INF def main():
    N,K=map(int,input().split())
    if (N-1)*(N-2)//2<K:
        print(-1)
    else:
        ans=[]
        for i in range(2,N+1):
            ans.append((1,i))
        i,j=2,3
        for _ in range((N-1)*(N-2)//2-K):
            ans.append((i,j))
            j+=1
            if j>N:
                i+=1
                j=i+1
        print(len(ans))
        for a in ans:
            print(*a) def main():
    N,K=map(int,input().split())
    if (N-1)*(N-2)//2<K:
        print(-1)
    else:
        ans=[]
        for i in range(2,N+1):
            ans.append((1,i))
        i,j=2,3
        for _ in range((N-1)*(N-2)//2-K):
            ans.append((i,j))
            j+=1
            if j>N:
                i+=1
                j=i+1
        print(len(ans))
        for a in ans:
            print(*a) main MOD=10**9+7 10**9+7 MOD int1=lambda x:int(x)-1 lambda x:int(x)-1 int1 YesNo=lambda b: bool([print('Yes')] if b else print('No')) lambda b: bool([print('Yes')] if b else print('No')) YesNo input=lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input YESNO=lambda b: bool([print('YES')] if b else print('NO')) lambda b: bool([print('YES')] if b else print('NO')) YESNO
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,K=map(int,input().split())
    if (N-1)*(N-2)//2<K:
        print(-1)
    else:
        ans=[]
        for i in range(2,N+1):
            ans.append((1,i))
        i,j=2,3
        for _ in range((N-1)*(N-2)//2-K):
            ans.append((i,j))
            j+=1
            if j>N:
                i+=1
                j=i+1
        print(len(ans))
        for a in ans:
            print(*a)

if __name__ == '__main__':
    main()
