K=int(input())
x=7
c=1
visited={7}
while x%K:
    x*=10
    x+=7
    x%=K
    c+=1
    z=x%K
    if z in visited:
        print(-1)
        exit()
    visited.add(x%K)
print(c) K=int(input()) K int(input()) int input() input x=7 x 7 c=1 c 1 visited={7} visited {7} while x%K:
    x*=10
    x+=7
    x%=K
    c+=1
    z=x%K
    if z in visited:
        print(-1)
        exit()
    visited.add(x%K) x%K x K x*=10 x 10 x+=7 x 7 x%=K x K c+=1 c 1 z=x%K z x%K x K if z in visited:
        print(-1)
        exit()
     z in visited z visited print(-1) print -1 exit() exit visited.add(x%K) visited.add visited add x%K x K print(c) print c c=1 1 c x+=7 7 x x=7 7 x c+=1 1 c visited={7} {7} visited x*=10 10 x x%=K K x z=x%K x%K z K=int(input()) int(input()) K
K=int(input())
x=7
c=1
visited={7}
while x%K:
    x*=10
    x+=7
    x%=K
    c+=1
    z=x%K
    if z in visited:
        print(-1)
        exit()
    visited.add(x%K)
print(c)
