#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
using namespace std;

int main() {
  int S;
  while (cin >> S) {
    set<int> W;
    while (W.size() < 4) {
      S += S/13 + 15;
      W.insert(S%100);
    }
    for (int m = 1;; m++) {
      char g1, g2;
      cin >> g1 >> g2;
      int G = (g1-'0')*10 + g2-'0';
      if (W.count(G)) {
        cout << "You hit a wumpus!" << endl;
        W.erase(G);
      }
      if (W.empty()) {
        cout << "Your score is " << m << " moves." << endl;
        break;
      }
      int d = 100;
      for (auto w : W) d = min(d, abs(w%10 - G%10) + abs(w/10 - G/10));
      cout << d << endl;
    }
  }
}
