k = int(eval(input()))

r = 0

for i in range(1, k+1):

    r = (r*10 + 7)%k

    if r == 0:

        print(i)

        exit()

print((-1))

def f(k):

    r = 7%k

    for i in range(k):

        if r == 0: return i+1

        r = (r*10 + 7)%k

    return -1



print((f(int(eval(input())))))

k = int(eval(input()))
r = 0
for i in range(1, k + 1):
    r = (r * 10 + 7) % k
    if r == 0:
        print(i)
        exit()
print((-1))

def f(k):
    r = 7 % k
    for i in range(k):
        if r == 0:
            return i + 1
        r = (r * 10 + 7) % k
    return -1


print((f(int(eval(input())))))

-k = int(eval(input())) -r = 0 -for i in range(1, k + 1): -    r = (r * 10 + 7) % k -    if r == 0: -        print(i) -        exit() -print((-1)) +def f(k): +    r = 7 % k +    for i in range(k): +        if r == 0: +            return i + 1 +        r = (r * 10 + 7) % k +    return -1 + + +print((f(int(eval(input())))))