// another fine solution by misof
#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <map>
using namespace std;

ifstream fdict("g2.in");
set<string> dict;
string word;
map<string,int> memo;

int solve(string prefix) {
  int &res = memo[prefix];
  if (res != 0) return res;
  res = -1;

  if (dict.count(prefix)) return res=1;

  set<string>::iterator it1, it2;
  it1 = dict.lower_bound(prefix);
  it2 = dict.upper_bound(prefix+'}');
  if (it1==it2) return res=1;

  for (char ch='a'; ch<='z'; ch++) { 
    int x = solve(prefix+ch);
    if (x<0 && res<0) res = 1-x;
    if (x<0) res = min(res,1-x);
    if (res<0) res = min(res,-x-1);
  }
  return res;
}

int main() {
  int N; fdict >> N; while (N--) { fdict >> word; dict.insert(word); }
  getline(cin,word);
  if (solve(word)<0) cout << "losing position" << endl; else
  for (char ch='a'; ch<='z'; ch++) { 
    int x = solve(word+ch);
    cout << ch << ": " << (x<0?" WIN":"loss") << " in " << (abs(x)-1) << " moves" << endl;
  }
  return 0;
}
// vim: fdm=marker:commentstring=\ \"\ %s:nowrap:autoread
