N, K = (int(i) for i in input().split())

#最大化すると(N-2)*(N-1)//2組
ma = (N-2)*(N-1)//2
cou = 0
if N == 2:
    if K > 0:
        print("-1")
    else:
        print("1")
        print("1 2")
else:
    if K > ma:
        print("-1")
    else:
        print(N-1 + ma - K)
        for i in range(1, N):
            print("{} {}".format(i, N))
        for i in range(1, N):
            for j in range(1, N):
                if cou >= ma - K:
                    exit()
                if i < j:
                    print(i, j)
                    cou += 1 int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i N, K = (int(i) for i in input().split()) N (int(i) for i in input().split()) K ma = (N-2)*(N-1)//2 ma (N-2)*(N-1)//2 (N-2)*(N-1) N-2 N 2 N-1 N 1 2 cou = 0 cou 0 if N == 2:
    if K > 0:
        print("-1")
    else:
        print("1")
        print("1 2")
else:
    if K > ma:
        print("-1")
    else:
        print(N-1 + ma - K)
        for i in range(1, N):
            print("{} {}".format(i, N))
        for i in range(1, N):
            for j in range(1, N):
                if cou >= ma - K:
                    exit()
                if i < j:
                    print(i, j)
                    cou += 1 N == 2 N 2 if K > 0:
        print("-1")
    else:
        print("1")
        print("1 2") K > 0 K 0 print("-1") print "-1" print("1") print "1" print("1 2") print "1 2" if K > ma:
        print("-1")
    else:
        print(N-1 + ma - K)
        for i in range(1, N):
            print("{} {}".format(i, N))
        for i in range(1, N):
            for j in range(1, N):
                if cou >= ma - K:
                    exit()
                if i < j:
                    print(i, j)
                    cou += 1 K > ma K ma print("-1") print "-1" print(N-1 + ma - K) print N-1 + ma - K N-1 + ma N-1 N 1 ma K for i in range(1, N):
            print("{} {}".format(i, N))
         i range(1, N) range 1 N print("{} {}".format(i, N)) print "{} {}".format(i, N) "{} {}".format "{} {}" format i N for i in range(1, N):
            for j in range(1, N):
                if cou >= ma - K:
                    exit()
                if i < j:
                    print(i, j)
                    cou += 1 i range(1, N) range 1 N for j in range(1, N):
                if cou >= ma - K:
                    exit()
                if i < j:
                    print(i, j)
                    cou += 1 j range(1, N) range 1 N if cou >= ma - K:
                    exit()
                 cou >= ma - K cou ma - K ma K exit() exit if i < j:
                    print(i, j)
                    cou += 1 i < j i j print(i, j) print i j cou += 1 cou 1 cou += 1 1 cou N, K = (int(i) for i in input().split()) (int(i) for i in input().split()) N cou = 0 0 cou K = (int(i) for i in input().split()) (int(i) for i in input().split()) K ma = (N-2)*(N-1)//2 (N-2)*(N-1)//2 ma
N, K = (int(i) for i in input().split())

#最大化すると(N-2)*(N-1)//2組
ma = (N-2)*(N-1)//2
cou = 0
if N == 2:
    if K > 0:
        print("-1")
    else:
        print("1")
        print("1 2")
else:
    if K > ma:
        print("-1")
    else:
        print(N-1 + ma - K)
        for i in range(1, N):
            print("{} {}".format(i, N))
        for i in range(1, N):
            for j in range(1, N):
                if cou >= ma - K:
                    exit()
                if i < j:
                    print(i, j)
                    cou += 1