import java.io.BufferedInputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class wumpus_da {

    private void work() {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int[][] ws = getWumpusii(s);
        boolean[] found = new boolean[4];
        int moves = 0;
        while (true) {
            moves++;
            int m = sc.nextInt();
            int r = m / 10;
            int c = m % 10;
            int minDist = 100;
            for (int i = 0; i < 4; i++) {
                if (!found[i]) {
                    int d = Math.abs(r - ws[i][0]) + Math.abs(c - ws[i][1]);
                    if (d == 0) {
                        found[i] = true;
                        System.out.println("You hit a wumpus!");
                        continue;
                    }

                    if (d < minDist) minDist = d;
                }
            }

            if (minDist == 100) {
                System.out.printf("Your score is %d moves.\n", moves);
                break;
            }

            System.out.println(minDist);
        }
    }

    private int[][] getWumpusii(int s) {
        int[][] ret = new int[4][2];
        int k = 0;
        while (k < 4) {
            s = s + (s / 13) + 15;
            int p = s % 100;
            int r = p / 10;
            int c = p % 10;
            boolean ok = true;
            for (int i = 0; i < k && ok; i++) {
                if (r == ret[i][0] && c == ret[i][1]) ok = false;
            }

            if (ok) {
                ret[k][0] = r;
                ret[k++][1] = c;
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        new wumpus_da().work();
    }
}
