#include <bits/stdc++.h>
using namespace std;
const int N = 50;
char g[N][N];
int f[N][N][N][N][2];
int n, m;
int sg(int x1, int y1, int x2, int y2, int flag) {
  if (x1 > x2 || y1 > y2) return 0;
  if (f[x1][y1][x2][y2][flag] != -1) return f[x1][y1][x2][y2][flag];
  bool st[400];
  memset(st, 0, sizeof st);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      int x = i + j, y = i - j + m;
      if ((i + j & 1) == flag || x1 > x || x > x2 || y1 > y || y > y2) continue;
      if (g[i][j] == 'L')
        st[sg(x + 1, y1, x2, y2, flag) ^ sg(x1, y1, x - 1, y2, flag)] = 1;
      if (g[i][j] == 'R')
        st[sg(x1, y + 1, x2, y2, flag) ^ sg(x1, y1, x2, y - 1, flag)] = 1;
      if (g[i][j] == 'X')
        st[sg(x + 1, y + 1, x2, y2, flag) ^ sg(x1, y1, x - 1, y - 1, flag) ^
           sg(x + 1, y1, x2, y - 1, flag) ^ sg(x1, y + 1, x - 1, y2, flag)] = 1;
    }
  }
  int res = 0;
  while (st[res]) ++res;
  return f[x1][y1][x2][y2][flag] = res;
}
int main() {
  scanf("%d%d", &n, &m);
  memset(f, -1, sizeof f);
  for (int i = 1; i <= n; ++i) scanf("%s", g[i] + 1);
  if (sg(1, 1, n + m, n + m, 1) ^ sg(1, 1, n + m, n + m, 0))
    puts("WIN");
  else
    puts("LOSE");
  return 0;
}
