//G. Hagopian--Kattis Hangman	
/*

Hangman

Hangman is a (somewhat macabre) word-guessing 
game that can be played by two people. Player 
1 thinks of a word consisting of n letters, 
and draws a row of n dashes on a piece of 
paper. These dashes correspond to the letters 
of the word, in the same order. Player 2 then 
attempts to discover the word by making a 
sequence of letter guesses. For each letter 
guessed by Player 2:

If the letter occurs one or more times in the 
word, Player 1 writes the letter above each 
corresponding dash.  
If the letter does not occur in the word, 
Player 1 adds one component to a drawing of 
a stick-figure man hanging on a gallows. The 
drawing (initially empty) has 10 possible 
components: base, vertical beam, horizontal 
beam, rope, head, torso, right leg, left leg, 
right arm, left arm. 

If Player 2 guesses all the letters in the 
word before the drawing of the hanging man 
is complete, then Player 2 wins (and Player 1 
loses). Otherwise, Player 2 loses (and Player 
1 wins).

Ned loves playing hangman, especially as 
Player 2, but he finds that he is not a very 
good letter guesser. To improve his chances, 
he decides to adopt a new strategy. For each 
word selected by Player 1, Ned chooses a 
random permutation of the letters of the 
alphabet, and then simply guesses letters in 
that order until he either wins or loses. 
Given the word and Ned’s permutation of the 
alphabet, determine the outcome of the game.

Input

The input consists of two lines representing 
a single game of Hangman. The first line 
contains the word to be guessed, a non-empty 
string of uppercase English alphabet letters 
(A–Z) of maximum length 16. The second line 
contains a permutation of the 26 letters of 
the English alphabet, also uppercase.

Output

If Ned wins the game by guessing letters in 
the order given by the permutation 
(proceeding from left to right), output “WIN”. 
Otherwise, output “LOSE”.

Sample Input 1 				Sample Output 1
HANGMAN
ABCDEFGHIJKLMNOPQRSTUVWXYZ  WIN

HANGMAN 9

Sample Input 2 				Sample Output 2

BANANA						LOSE
ABCDEFGHIJKLMNOPQRSTUVWXYZ

Sample Input 3 				Sample Output 3

RAINBOWS					WIN
USIANBVLOJRKWXZCTQGHPFMYDE

RAINBOWS  
*/

#include <iostream>
#include <string>
#include <map>  // for pair
using namespace std;

void score_letter(pair<int,int>& score, string word, char letter) {
	int successes{};
	for (int i = 0; i < word.length(); ++i) {
		if (word[i] == letter) ++successes;
	}
	if (successes > 0) score.first += successes;
	else ++score.second;
}

int main() {
	string word, alpha;
	pair<int, int> score = make_pair(0, 0);
	cin >> word >> alpha;
	// score = pair<0,0> wins and losses
	// while score.first < word.length() && score.second < 10
	// score ith letter of alpha
	//    if alpha[i] is in word
	//    then count the number of times
	//    and add that count to wins score
	//    else increment losses by 1
	int i = 0;
	while(score.first != word.size() && score.second != 10) {
		score_letter(score, word, alpha[i++]);
		if (score.second == 10) {
			cout << "LOSE";
		}
		if (score.first == word.size()) {
			cout << "WIN";
		}
	}
}


