k = int(eval(input()))

mod = 7 % k

counter = 1

memo = 1

mod_map = set()

mod_map.add(mod)

while mod != 0:

    mod = ((mod * 10) % k + 7) % k

    if mod not in mod_map:

        mod_map.add(mod)

    else:

        counter = -1

        break

    counter += 1

    if mod == 0:

        break

print(counter)

k = int(eval(input()))

mod = 0



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

    mod = ((mod * 10) % k + 7) % k

    if mod == 0:

        print(i)

        break

else:

    print((-1))

k = int(eval(input()))
mod = 7 % k
counter = 1
memo = 1
mod_map = set()
mod_map.add(mod)
while mod != 0:
    mod = ((mod * 10) % k + 7) % k
    if mod not in mod_map:
        mod_map.add(mod)
    else:
        counter = -1
        break
    counter += 1
    if mod == 0:
        break
print(counter)

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

-mod = 7 % k -counter = 1 -memo = 1 -mod_map = set() -mod_map.add(mod) -while mod != 0: +mod = 0 +for i in range(1, k + 1): -    if mod not in mod_map: -        mod_map.add(mod) -    else: -        counter = -1 +    if mod == 0: +        print(i) -    counter += 1 -    if mod == 0: -        break -print(counter) +else: +    print((-1))