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