#include "iostream"
#include "vector"
#include "string.h"
#include "set"
using namespace std;
int mem[200][200];
int Grundy (int w, int h)
{
if (mem[w][h]! =-1)
return mem[w][h];
int i;
set<int> s;
for (i=2; w-i>=2; i++) //If the width is 1 after cutting, the Grundy value of the output of the two sheets is G1, G2, and the Grundy value of the two sheets
corresponding states G1 ^ G2
S.insert (Grundy (i, h) ^ Grundy (w-i, h));
}
for (i=2; h-i>=2; i++) //If the height is 1 after cut, the output is
{
S.insert (Grundy (W, i) ^ Grundy (W, H-i));
}
int g = 0;
while (S.count (g)) //Find the minimum value g++ not contained in S
;
return mem[w][h] = g;
}
int main ()
{
int w, h;
cout << "Width w =" of the paper;
Cin >> W;
cout << "Height of paper h =";
Cin >> H;
memset (Mem,-1, sizeof (MEM));
int result = Grundy (W, h);
if (result)
cout << "WIN" << Endl;
else
cout << "lose" << Endl;
return 0;
}