k = int(input())
if k % 7 == 0:
    l = 9*k // 7
else:
    l = 9*k
if l % 2 == 0 or l % 5 == 0:
    print(-1)
else:
    pmo = 1
    for i in range(1, l + 1):
        mo = (pmo * 10) % l
        if mo == 1:
            print(i)
            break
        else:
            pmo = mo k = int(input()) k int(input()) int input() input if k % 7 == 0:
    l = 9*k // 7
else:
    l = 9*k k % 7 == 0 k % 7 k 7 0 l = 9*k // 7 l 9*k // 7 9*k 9 k 7 l = 9*k l 9*k 9 k if l % 2 == 0 or l % 5 == 0:
    print(-1)
else:
    pmo = 1
    for i in range(1, l + 1):
        mo = (pmo * 10) % l
        if mo == 1:
            print(i)
            break
        else:
            pmo = mo l % 2 == 0 or l % 5 == 0 l % 2 == 0 l % 2 l 2 0 l % 5 == 0 l % 5 l 5 0 print(-1) print -1 pmo = 1 pmo 1 for i in range(1, l + 1):
        mo = (pmo * 10) % l
        if mo == 1:
            print(i)
            break
        else:
            pmo = mo i range(1, l + 1) range 1 l + 1 l 1 mo = (pmo * 10) % l mo (pmo * 10) % l pmo * 10 pmo 10 l if mo == 1:
            print(i)
            break
        else:
            pmo = mo mo == 1 mo 1 print(i) print i break pmo = mo pmo mo l = 9*k // 7 9*k // 7 l mo = (pmo * 10) % l (pmo * 10) % l mo l = 9*k 9*k l k = int(input()) int(input()) k pmo = 1 1 pmo pmo = mo mo pmo
k = int(input())
if k % 7 == 0:
    l = 9*k // 7
else:
    l = 9*k
if l % 2 == 0 or l % 5 == 0:
    print(-1)
else:
    pmo = 1
    for i in range(1, l + 1):
        mo = (pmo * 10) % l
        if mo == 1:
            print(i)
            break
        else:
            pmo = mo