k = int(eval(input()))

if k%2 == 0:

    ans = -1

else:

    x = 0

    ans = -1

    for i in range(10**6+1):

        x += 7*pow(10, i, k)

        x %= k

        if x%k == 0:

            ans = i+1

            break

print(ans)
k = int(eval(input()))

x = 0

ans = -1

for i in range(10**6+1):

    x = 10*x + 7

    x %= k

    if x == 0:

        ans = i+1

        break

print(ans)

k = int(eval(input()))
if k % 2 == 0:
    ans = -1
else:
    x = 0
    ans = -1
    for i in range(10**6 + 1):
        x += 7 * pow(10, i, k)
        x %= k
        if x % k == 0:
            ans = i + 1
            break
print(ans)

k = int(eval(input()))
x = 0
ans = -1
for i in range(10**6 + 1):
    x = 10 * x + 7
    x %= k
    if x == 0:
        ans = i + 1
        break
print(ans)

-if k % 2 == 0: -    ans = -1 -else: -    x = 0 -    ans = -1 -    for i in range(10**6 + 1): -        x += 7 * pow(10, i, k) -        x %= k -        if x % k == 0: -            ans = i + 1 -            break +x = 0 +ans = -1 +for i in range(10**6 + 1): +    x = 10 * x + 7 +    x %= k +    if x == 0: +        ans = i + 1 +        break