k = int(eval(input()))



now = 7

cnt = 1

used = [False] * k

ten = 10

while not used[now % k]:

    if now % k == 0:

        print(cnt)

        exit()

    used[now % k] = True

    now = (now + ten * 7) % k

    ten = ten * 10 % k

    cnt += 1

print((-1))

k = int(eval(input()))

n = 7

for i in range(k):

    if n % k == 0:

        print((i + 1))

        exit()

    n = (n * 10 + 7) % k

print((-1))

k = int(eval(input()))
now = 7
cnt = 1
used = [False] * k
ten = 10
while not used[now % k]:
    if now % k == 0:
        print(cnt)
        exit()
    used[now % k] = True
    now = (now + ten * 7) % k
    ten = ten * 10 % k
    cnt += 1
print((-1))

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

-now = 7 -cnt = 1 -used = [False] * k -ten = 10 -while not used[now % k]: -    if now % k == 0: -        print(cnt) +n = 7 +for i in range(k): +    if n % k == 0: +        print((i + 1)) -    used[now % k] = True -    now = (now + ten * 7) % k -    ten = ten * 10 % k -    cnt += 1 +    n = (n * 10 + 7) % k