func main() {
    let k = 999983 //Int(readLine()!)!
    var setOfRemainder = Set<Int>()
    var i = 1
    var num = 1
    var remainder = 0
    var currentRemainder = 0
    while true {
        currentRemainder = (num * 7 + remainder) % k
        if currentRemainder == 0 {
            print(i)
            break
        } else if setOfRemainder.contains(currentRemainder){
            print(-1)
            break
        } else {
            remainder = currentRemainder
            setOfRemainder.insert(remainder)
            print(num, setOfRemainder.description)
            num = num * 10 % k
            i += 1
        }
    }
}

main()
