K = int(eval(input()))

L = 0

if K % 7 == 0:

  L = 9*K//7

else:

  L = 9*K

ans = -1

a = 10

for i in range(1,L+1,1):

  if a % L == 1:

    ans = i

    break

  a = (a % L) * 10 



print(ans)
K = int(eval(input()))

L = 0

if K % 7 == 0:

  L = 9*K//7

else:

  L = 9*K

  

ans = -1

s = 10

for i in range(1,L,1):

  if s % L == 1:

    ans = i

    break

  s = s % L * 10

print(ans)
K = int(eval(input()))
L = 0
if K % 7 == 0:
    L = 9 * K // 7
else:
    L = 9 * K
ans = -1
a = 10
for i in range(1, L + 1, 1):
    if a % L == 1:
        ans = i
        break
    a = (a % L) * 10
print(ans)

K = int(eval(input()))
L = 0
if K % 7 == 0:
    L = 9 * K // 7
else:
    L = 9 * K
ans = -1
s = 10
for i in range(1, L, 1):
    if s % L == 1:
        ans = i
        break
    s = s % L * 10
print(ans)

-a = 10 -for i in range(1, L + 1, 1): -    if a % L == 1: +s = 10 +for i in range(1, L, 1): +    if s % L == 1: -    a = (a % L) * 10 +    s = s % L * 10