k = int(eval(input()))

x, i = 0, 0

r = set()

while True:

    x = (x * 10 + 7) % k

    i += 1

    if x == 0:

        break

    if x in r:

        print((-1))

        quit()

    r.add(x)

print(i)
def power(x, n, mod):

    ans = 1

    while n > 0:

        if n % 2 == 1:

            ans = ans * x % mod

        n //= 2

        x = x * x % mod

    return ans



def eular(n):

    ans = 1

    if n % 2 == 0:

        x = 1

        while n % 2 == 0:

            n //= 2

            x *= 2

        ans *= x - x // 2

    i = 3

    while i * i <= n:

        if n % i == 0:

            x = 1

            while n % i == 0:

                n //= i

                x *= i

            ans *= x - x // i

        i += 2

    if n != 1:

        ans *= n - 1

    return ans



k = int(eval(input()))



if k % 2 == 0 or k % 5 == 0:

    print((-1))

    quit()

elif k % 7 == 0:

    l = 9 * k // 7

else:

    l = 9 * k



phi_l = eular(l)

ans = phi_l

d, x = 10, 1

while x * x <= phi_l:

    if phi_l % x == 0:

        if d % l == 1:

            ans = x

            break

        else:

            y = phi_l // x

            if pow(10, y, l) == 1:

                ans = y

    d = d * 10 % l

    x += 1

print(ans)



k = int(eval(input()))
x, i = 0, 0
r = set()
while True:
    x = (x * 10 + 7) % k
    i += 1
    if x == 0:
        break
    if x in r:
        print((-1))
        quit()
    r.add(x)
print(i)

def power(x, n, mod):
    ans = 1
    while n > 0:
        if n % 2 == 1:
            ans = ans * x % mod
        n //= 2
        x = x * x % mod
    return ans


def eular(n):
    ans = 1
    if n % 2 == 0:
        x = 1
        while n % 2 == 0:
            n //= 2
            x *= 2
        ans *= x - x // 2
    i = 3
    while i * i <= n:
        if n % i == 0:
            x = 1
            while n % i == 0:
                n //= i
                x *= i
            ans *= x - x // i
        i += 2
    if n != 1:
        ans *= n - 1
    return ans


k = int(eval(input()))
if k % 2 == 0 or k % 5 == 0:
    print((-1))
    quit()
elif k % 7 == 0:
    l = 9 * k // 7
else:
    l = 9 * k
phi_l = eular(l)
ans = phi_l
d, x = 10, 1
while x * x <= phi_l:
    if phi_l % x == 0:
        if d % l == 1:
            ans = x
            break
        else:
            y = phi_l // x
            if pow(10, y, l) == 1:
                ans = y
    d = d * 10 % l
    x += 1
print(ans)

+def power(x, n, mod): +    ans = 1 +    while n > 0: +        if n % 2 == 1: +            ans = ans * x % mod +        n //= 2 +        x = x * x % mod +    return ans + + +def eular(n): +    ans = 1 +    if n % 2 == 0: +        x = 1 +        while n % 2 == 0: +            n //= 2 +            x *= 2 +        ans *= x - x // 2 +    i = 3 +    while i * i <= n: +        if n % i == 0: +            x = 1 +            while n % i == 0: +                n //= i +                x *= i +            ans *= x - x // i +        i += 2 +    if n != 1: +        ans *= n - 1 +    return ans + + -x, i = 0, 0 -r = set() -while True: -    x = (x * 10 + 7) % k -    i += 1 -    if x == 0: -        break -    if x in r: -        print((-1)) -        quit() -    r.add(x) -print(i) +if k % 2 == 0 or k % 5 == 0: +    print((-1)) +    quit() +elif k % 7 == 0: +    l = 9 * k // 7 +else: +    l = 9 * k +phi_l = eular(l) +ans = phi_l +d, x = 10, 1 +while x * x <= phi_l: +    if phi_l % x == 0: +        if d % l == 1: +            ans = x +            break +        else: +            y = phi_l // x +            if pow(10, y, l) == 1: +                ans = y +    d = d * 10 % l +    x += 1 +print(ans)