k = int(eval(input()))

num = 0

if not k%2:

    print((-1))

else:

    for i in range(k):

        num = (num*10+7)%k

        if num == 0:

            print((i+1))

            break

    else:

        print((-1))
K = int(eval(input()))



ans = 1

num = 0

seven = 7



if not K%2:

    print((-1))

else:

    for i in range(K):

        num = num + seven

        seven = seven*10%K

        num = num%K

        if num == 0:

            print(ans)

            break

        ans += 1

    else:

        print((-1))
k = int(eval(input()))
num = 0
if not k % 2:
    print((-1))
else:
    for i in range(k):
        num = (num * 10 + 7) % k
        if num == 0:
            print((i + 1))
            break
    else:
        print((-1))

K = int(eval(input()))
ans = 1
num = 0
seven = 7
if not K % 2:
    print((-1))
else:
    for i in range(K):
        num = num + seven
        seven = seven * 10 % K
        num = num % K
        if num == 0:
            print(ans)
            break
        ans += 1
    else:
        print((-1))

-k = int(eval(input())) +K = int(eval(input())) +ans = 1 -if not k % 2: +seven = 7 +if not K % 2: -    for i in range(k): -        num = (num * 10 + 7) % k +    for i in range(K): +        num = num + seven +        seven = seven * 10 % K +        num = num % K -            print((i + 1)) +            print(ans) +        ans += 1