#include <bits/stdc++.h>
using namespace std;
const int MAXN = 40 + 10;
int a[MAXN][MAXN], sg[MAXN][MAXN][MAXN][MAXN], n, m, lab[300], N, M;
char str[MAXN][MAXN];
void init() {
  scanf("%d%d", &n, &m);
  lab[(int)'X'] = 1, lab[(int)'L'] = 2, lab[(int)'R'] = 3;
  for (int i = 1; i <= n; ++i) scanf("%s", str[i] + 1);
}
int calc(int xl, int yl, int xr, int yr) {
  if (yr < yl || xr < xl) return 0;
  if (sg[xl][yl][xr][yr] != -1) return sg[xl][yl][xr][yr];
  vector<int> S;
  for (int i = xl; i <= xr; ++i)
    for (int j = yl; j <= yr; ++j) {
      int Nsg = -1;
      if (a[i][j] == 1)
        Nsg = calc(xl, yl, i - 1, j - 1) ^ calc(i + 1, yl, xr, j - 1) ^
              calc(xl, j + 1, i - 1, yr) ^ calc(i + 1, j + 1, xr, yr);
      if (a[i][j] == 2) Nsg = calc(xl, yl, i - 1, yr) ^ calc(i + 1, yl, xr, yr);
      if (a[i][j] == 3) Nsg = calc(xl, yl, xr, j - 1) ^ calc(xl, j + 1, xr, yr);
      if (Nsg != -1) S.push_back(Nsg);
    }
  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());
  int cur = -1;
  for (int i = 0; i < (int)S.size(); ++i)
    if (cur + 1 != S[i])
      break;
    else
      cur = S[i];
  sg[xl][yl][xr][yr] = cur + 1;
  return cur + 1;
}
int solve(bool flag) {
  memset(sg, -1, sizeof(sg));
  memset(a, 0, sizeof(a));
  N = M = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (((i + j) & 1) == flag) {
        int x = (i + j) / 2, y = (i - j + m + 1) / 2;
        a[x][y] = lab[(int)str[i][j]];
        N = max(N, x), M = max(M, y);
      }
  return calc(1, 1, N, M);
}
int main() {
  init();
  cout << ((solve(0) ^ solve(1)) ? "WIN" : "LOSE") << endl;
  fclose(stdin);
  fclose(stdout);
  return 0;
}
