#include <cmath>
#include <limits>
#include <iostream>
#include <vector>
#include <set>

int main()
{
    int seed;
    std::cin >> seed;
    
    std::set<int> locs;
    while(locs.size() < 4)
    {
        seed = seed + (seed / 13) + 15;
        locs.insert( seed % 100);
    }   
    
    std::vector<int> wumpuses(4);
    std::vector<bool> dead(4);
    int idx=0;
    for(auto it : locs)
        wumpuses[idx++] = it;
    
    int moves = 0;
    while(true)
    {
        int move = 0;
        std::cin >> move;
        moves++;
        for(int i=0; i<4; i++)
        {
            if(wumpuses[i] == move && !dead[i])
            {
                dead[i] = true;
                std::cout << "You hit a wumpus!" << std::endl;
            }
        }
        
        bool found = false;
        int dist = std::numeric_limits<int>::max();
        for(int i=0; i<4; i++)
        {
            if(dead[i])
                continue;
            int wx = wumpuses[i] / 10;
            int mx = move / 10;
            int wy = wumpuses[i] % 10;
            int my = move % 10;
            int thisdist = std::abs(mx-wx) + std::abs(my-wy);
            if(thisdist < dist)
            {
                found = true;
                dist = thisdist;
            }
        }
        if(found)
            std::cout << dist << std::endl;
        else
        {
            std::cout << "Your score is " << moves << " moves." << std::endl;
            return 0;
        }
    }
}
