#include <bits/stdc++.h>
using namespace std;
char board[2][22][22], all[22][22];
int ch[2], cw[2];
bool been[2][30][30][30][30];
short cache[2][30][30][30][30];
inline bool legal(const int &a, const int &b, const int &c) {
  return a <= b && b < c;
}
void transform(int h, int w, char src[][22], char dest[][22], int parity) {
  int pw = h / 2;
  for (int i = 0; i < 20; i++) {
    int sh = 2 * i + parity;
    for (int j = 0; j < 40; j++) {
      if (legal(0, sh - j, h) && legal(0, j, w)) {
        dest[i][j + pw] = src[sh - j][j];
        ch[parity] = max(ch[parity], i);
        cw[parity] = max(cw[parity], j + pw);
      }
    }
    pw--;
  }
}
int sg(char p, int h, int y, int w, int x) {
  int ret = 0;
  if (y <= h || x <= w) {
    return 0;
  }
  if (been[p][h][y][w][x]) return cache[p][h][y][w][x];
  been[p][h][y][w][x] = true;
  bool b[99];
  memset(b, 0, sizeof(b));
  for (int i = h; i < y; i++) {
    for (int j = w; j < x; j++) {
      switch (board[p][i][j]) {
        case 'L':
          b[sg(p, h, i, w, x) ^ sg(p, i + 1, y, w, x)] = true;
          break;
        case 'R':
          b[sg(p, h, y, w, j) ^ sg(p, h, y, j + 1, x)] = true;
          break;
        case 'X':
          b[sg(p, h, i, w, j) ^ sg(p, h, i, j + 1, x) ^ sg(p, i + 1, y, w, j) ^
            sg(p, i + 1, y, j + 1, x)] = true;
          break;
        default:
          continue;
      }
    }
  }
  while (b[ret]) ret++;
  return cache[p][h][y][w][x] = ret;
}
int main() {
  int h, w;
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; i++) {
    scanf("%s", all[i]);
  }
  for (int i = 0; i < 2; i++) {
    transform(h, w, all, board[i], i);
  }
  for (int i = 0; i < 2; i++) {
    ch[i]++;
    cw[i]++;
    for (int a = 0; a < ch[i]; a++) {
      for (int b = 0; b < cw[i]; b++) {
      }
    }
  }
  int ret = 0;
  for (int i = 0; i < 2; i++) {
    ret ^= sg(i, 0, ch[i], 0, cw[i]);
  }
  printf("%s\n", ret ? "WIN" : "LOSE");
  return 0;
}
