#131_E
n,k=map(int,input().split())
edges=[[1,i] for i in range(2,n+1)]
cnt=(n-1)*(n-2)//2
ans=n-1
if cnt<k:
    print(-1)
else:
    for i in range(2,n):
        for j in range(i+1,n+1):
            if cnt>k:
                cnt-=1
                ans+=1
                edges.append([i,j])
            else:
                break
    print(ans)
    for edge in edges:
        print(*edge) n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k [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 edges=[[1,i] for i in range(2,n+1)] edges [[1,i] for i in range(2,n+1)] cnt=(n-1)*(n-2)//2 cnt (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 ans=n-1 ans n-1 n 1 if cnt<k:
    print(-1)
else:
    for i in range(2,n):
        for j in range(i+1,n+1):
            if cnt>k:
                cnt-=1
                ans+=1
                edges.append([i,j])
            else:
                break
    print(ans)
    for edge in edges:
        print(*edge) cnt<k cnt k print(-1) print -1 for i in range(2,n):
        for j in range(i+1,n+1):
            if cnt>k:
                cnt-=1
                ans+=1
                edges.append([i,j])
            else:
                break
     i range(2,n) range 2 n for j in range(i+1,n+1):
            if cnt>k:
                cnt-=1
                ans+=1
                edges.append([i,j])
            else:
                break
     j range(i+1,n+1) range i+1 i 1 n+1 n 1 if cnt>k:
                cnt-=1
                ans+=1
                edges.append([i,j])
            else:
                break
     cnt>k cnt k cnt-=1 cnt 1 ans+=1 ans 1 edges.append([i,j]) edges.append edges append [i,j] i j break print(ans) print ans for edge in edges:
        print(*edge) edge edges print(*edge) print *edge edge ans=n-1 n-1 ans n,k=map(int,input().split()) map(int,input().split()) n k=map(int,input().split()) map(int,input().split()) k ans+=1 1 ans edges=[[1,i] for i in range(2,n+1)] [[1,i] for i in range(2,n+1)] edges cnt-=1 1 cnt cnt=(n-1)*(n-2)//2 (n-1)*(n-2)//2 cnt
#131_E
n,k=map(int,input().split())
edges=[[1,i] for i in range(2,n+1)]
cnt=(n-1)*(n-2)//2
ans=n-1
if cnt<k:
    print(-1)
else:
    for i in range(2,n):
        for j in range(i+1,n+1):
            if cnt>k:
                cnt-=1
                ans+=1
                edges.append([i,j])
            else:
                break
    print(ans)
    for edge in edges:
        print(*edge)