#include <bits/stdc++.h>
using namespace std;
const int maxn = 45;
int n, m;
char G[maxn][maxn];
int sg[maxn][maxn][maxn][maxn][2];
int SG(int x0, int x1, int y0, int y1, int d) {
  int &g = sg[x0][x1][y0][y1][d];
  if (g != -1) return g;
  char s[maxn * 2 + 1] = {0};
  for (int y = 0; y < n; ++y) {
    for (int x = 0; x < m; ++x) {
      if (((x + y) & 1) == d) {
        int x_ = y + x, y_ = y - x + m;
        if (x0 <= x_ && x_ < x1 && y0 <= y_ && y_ < y1) {
          int tmp;
          if (G[y][x] == 'L') {
            tmp = SG(x0, x_, y0, y1, d) ^ SG(x_ + 1, x1, y0, y1, d);
          }
          if (G[y][x] == 'R') {
            tmp = SG(x0, x1, y0, y_, d) ^ SG(x0, x1, y_ + 1, y1, d);
          }
          if (G[y][x] == 'X') {
            tmp = SG(x0, x_, y0, y_, d) ^ SG(x0, x_, y_ + 1, y1, d) ^
                  SG(x_ + 1, x1, y0, y_, d) ^ SG(x_ + 1, x1, y_ + 1, y1, d);
          }
          s[tmp] = 1;
        }
      }
    }
  }
  while (s[++g])
    ;
  return g;
}
int main() {
  while (scanf("%d %d", &n, &m) == 2) {
    for (int i = 0; i < n; ++i) {
      scanf(" %s", G[i]);
    }
    memset(sg, -1, sizeof sg);
    if ((SG(0, n + m, 0, n + m, 0) ^ SG(0, n + m, 0, n + m, 1)) > 0)
      puts("WIN");
    else
      puts("LOSE");
  }
  return 0;
}
