K = int(input())

if K % 7 == 0:
    K //= 7

L = 9 * K

if L % 2 == 0 or L % 5 == 0:
    ans = -1
else:
    ans = 0
    R = 10
    while 1:
        ans += 1
        if R % L == 1:
            break
        else:
            R = (10 * R) % L

print(ans) K = int(input()) K int(input()) int input() input if K % 7 == 0:
    K //= 7 K % 7 == 0 K % 7 K 7 0 K //= 7 K 7 L = 9 * K L 9 * K 9 K if L % 2 == 0 or L % 5 == 0:
    ans = -1
else:
    ans = 0
    R = 10
    while 1:
        ans += 1
        if R % L == 1:
            break
        else:
            R = (10 * R) % L L % 2 == 0 or L % 5 == 0 L % 2 == 0 L % 2 L 2 0 L % 5 == 0 L % 5 L 5 0 ans = -1 ans -1 ans = 0 ans 0 R = 10 R 10 while 1:
        ans += 1
        if R % L == 1:
            break
        else:
            R = (10 * R) % L 1 ans += 1 ans 1 if R % L == 1:
            break
        else:
            R = (10 * R) % L R % L == 1 R % L R L 1 break R = (10 * R) % L R (10 * R) % L 10 * R 10 R L print(ans) print ans ans += 1 1 ans R = 10 10 R R = (10 * R) % L (10 * R) % L R K //= 7 7 K K = int(input()) int(input()) K ans = -1 -1 ans ans = 0 0 ans L = 9 * K 9 * K L
K = int(input())

if K % 7 == 0:
    K //= 7

L = 9 * K

if L % 2 == 0 or L % 5 == 0:
    ans = -1
else:
    ans = 0
    R = 10
    while 1:
        ans += 1
        if R % L == 1:
            break
        else:
            R = (10 * R) % L

print(ans)