import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())

    if K > (N - 1) * (N - 2) // 2:
        print('-1')
        return
        
    m = (N - 1) * (N - 2) // 2 - K
    M = N - 1 + m
    
    print(M)
    for i in range(2, N+1):
        print(1, i)
    
    i, j = 2, 3
    for _ in range(m):
        print(i, j)
        if j == N:
            i += 1
            j = i + 1
        else:
            j += 1

    return


if __name__ == '__main__':
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 MOD = 1000000007 MOD 1000000007 def main():
    N, K = map(int, readline().split())

    if K > (N - 1) * (N - 2) // 2:
        print('-1')
        return
        
    m = (N - 1) * (N - 2) // 2 - K
    M = N - 1 + m
    
    print(M)
    for i in range(2, N+1):
        print(1, i)
    
    i, j = 2, 3
    for _ in range(m):
        print(i, j)
        if j == N:
            i += 1
            j = i + 1
        else:
            j += 1

    return main N, K = map(int, readline().split()) N map(int, readline().split()) map int readline().split() ().split () readline split K if K > (N - 1) * (N - 2) // 2:
        print('-1')
        return
        
     K > (N - 1) * (N - 2) // 2 K (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 print('-1') print '-1' return m = (N - 1) * (N - 2) // 2 - K m (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 M = N - 1 + m M N - 1 + m N - 1 N 1 m print(M) print M for i in range(2, N+1):
        print(1, i)
    
     i range(2, N+1) range 2 N+1 N 1 print(1, i) print 1 i i, j = 2, 3 i 2 j 3 for _ in range(m):
        print(i, j)
        if j == N:
            i += 1
            j = i + 1
        else:
            j += 1

     _ range(m) range m print(i, j) print i j if j == N:
            i += 1
            j = i + 1
        else:
            j += 1

     j == N j N i += 1 i 1 j = i + 1 j i + 1 i 1 j += 1 j 1 return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.readline sys.stdin.readline readline def main():
    N, K = map(int, readline().split())

    if K > (N - 1) * (N - 2) // 2:
        print('-1')
        return
        
    m = (N - 1) * (N - 2) // 2 - K
    M = N - 1 + m
    
    print(M)
    for i in range(2, N+1):
        print(1, i)
    
    i, j = 2, 3
    for _ in range(m):
        print(i, j)
        if j == N:
            i += 1
            j = i + 1
        else:
            j += 1

    return def main():
    N, K = map(int, readline().split())

    if K > (N - 1) * (N - 2) // 2:
        print('-1')
        return
        
    m = (N - 1) * (N - 2) // 2 - K
    M = N - 1 + m
    
    print(M)
    for i in range(2, N+1):
        print(1, i)
    
    i, j = 2, 3
    for _ in range(m):
        print(i, j)
        if j == N:
            i += 1
            j = i + 1
        else:
            j += 1

    return main INF = 1 << 60 1 << 60 INF read = sys.stdin.read sys.stdin.read read MOD = 1000000007 1000000007 MOD readlines = sys.stdin.readlines sys.stdin.readlines readlines
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())

    if K > (N - 1) * (N - 2) // 2:
        print('-1')
        return
        
    m = (N - 1) * (N - 2) // 2 - K
    M = N - 1 + m
    
    print(M)
    for i in range(2, N+1):
        print(1, i)
    
    i, j = 2, 3
    for _ in range(m):
        print(i, j)
        if j == N:
            i += 1
            j = i + 1
        else:
            j += 1

    return


if __name__ == '__main__':
    main()
