k=int(input())
if k%7==0:
    k = 9*k//7
else:
    k *= 9
f=10%k
r = -1
for i in range(10**7):
    if f==1:
        r = i+1
        break
    else:
        f = f*10%k
print(r) k=int(input()) k int(input()) int input() input if k%7==0:
    k = 9*k//7
else:
    k *= 9 k%7==0 k%7 k 7 0 k = 9*k//7 k 9*k//7 9*k 9 k 7 k *= 9 k 9 f=10%k f 10%k 10 k r = -1 r -1 for i in range(10**7):
    if f==1:
        r = i+1
        break
    else:
        f = f*10%k i range(10**7) range 10**7 10 7 if f==1:
        r = i+1
        break
    else:
        f = f*10%k f==1 f 1 r = i+1 r i+1 i 1 break f = f*10%k f f*10%k f*10 f 10 k print(r) print r r = -1 -1 r f = f*10%k f*10%k f k = 9*k//7 9*k//7 k f=10%k 10%k f r = i+1 i+1 r k=int(input()) int(input()) k k *= 9 9 k
k=int(input())
if k%7==0:
    k = 9*k//7
else:
    k *= 9
f=10%k
r = -1
for i in range(10**7):
    if f==1:
        r = i+1
        break
    else:
        f = f*10%k
print(r)