n,k=map(int,input().split())
if k>(n-1)*n//2-(n-1):
    print(-1)
else:
    ans=[(1,i) for i in range(2,n+1)]
    lestnum=(n-1)*n//2-(n-1)-k
    for i in range(2,n):
        for j in range(i+1,n+1):
            if lestnum!=0:
                ans.append((i,j))
                lestnum-=1
    print(len(ans))
    for i in ans:
        print(" ".join(map(str,i))) n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k if k>(n-1)*n//2-(n-1):
    print(-1)
else:
    ans=[(1,i) for i in range(2,n+1)]
    lestnum=(n-1)*n//2-(n-1)-k
    for i in range(2,n):
        for j in range(i+1,n+1):
            if lestnum!=0:
                ans.append((i,j))
                lestnum-=1
    print(len(ans))
    for i in ans:
        print(" ".join(map(str,i))) k>(n-1)*n//2-(n-1) k (n-1)*n//2-(n-1) (n-1)*n//2 (n-1)*n n-1 n 1 n 2 n-1 n 1 print(-1) print -1 (1,i) for i in range(2,n+1) for i in range(2,n+1) i range(2,n+1) range 2 n+1 n 1 for i in range(2,n+1) (1,i) 1 i ans=[(1,i) for i in range(2,n+1)] ans [(1,i) for i in range(2,n+1)] lestnum=(n-1)*n//2-(n-1)-k lestnum (n-1)*n//2-(n-1)-k (n-1)*n//2-(n-1) (n-1)*n//2 (n-1)*n n-1 n 1 n 2 n-1 n 1 k for i in range(2,n):
        for j in range(i+1,n+1):
            if lestnum!=0:
                ans.append((i,j))
                lestnum-=1
     i range(2,n) range 2 n for j in range(i+1,n+1):
            if lestnum!=0:
                ans.append((i,j))
                lestnum-=1
     j range(i+1,n+1) range i+1 i 1 n+1 n 1 if lestnum!=0:
                ans.append((i,j))
                lestnum-=1
     lestnum!=0 lestnum 0 ans.append((i,j)) ans.append ans append (i,j) i j lestnum-=1 lestnum 1 print(len(ans)) print len(ans) len ans for i in ans:
        print(" ".join(map(str,i))) i ans print(" ".join(map(str,i))) print " ".join(map(str,i)) " ".join " " join map(str,i) map str i k=map(int,input().split()) map(int,input().split()) k n,k=map(int,input().split()) map(int,input().split()) n lestnum-=1 1 lestnum ans=[(1,i) for i in range(2,n+1)] [(1,i) for i in range(2,n+1)] ans lestnum=(n-1)*n//2-(n-1)-k (n-1)*n//2-(n-1)-k lestnum
n,k=map(int,input().split())
if k>(n-1)*n//2-(n-1):
    print(-1)
else:
    ans=[(1,i) for i in range(2,n+1)]
    lestnum=(n-1)*n//2-(n-1)-k
    for i in range(2,n):
        for j in range(i+1,n+1):
            if lestnum!=0:
                ans.append((i,j))
                lestnum-=1
    print(len(ans))
    for i in ans:
        print(" ".join(map(str,i)))