#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[30][30], d[30][30];
int sg[30][30][30][30];
bool used[30 * 30 * 30];
bool check(int xl, int yl, int xr, int yr) {
  for (int i = xl; i <= xr; i++)
    for (int j = yl; j <= yr; j++)
      if (d[i][j] == 'L' || d[i][j] == 'R' || d[i][j] == 'X') return 1;
  return 0;
}
int get_sg(int xl, int yl, int xr, int yr) {
  if (sg[xl][yl][xr][yr] != -1) return sg[xl][yl][xr][yr];
  if (check(xl, yl, xr, yr) == 0) {
    sg[xl][yl][xr][yr] = 0;
    return 0;
  }
  for (int i = xl; i <= xr; i++)
    for (int j = yl; j <= yr; j++) {
      if (d[i][j] == 'L') {
        get_sg(xl, yl, i - 1, yr);
        get_sg(i + 1, yl, xr, yr);
      }
      if (d[i][j] == 'R') {
        get_sg(xl, yl, xr, j - 1);
        get_sg(xl, j + 1, xr, yr);
      }
      if (d[i][j] == 'X') {
        get_sg(xl, yl, i - 1, j - 1);
        get_sg(xl, j + 1, i - 1, yr);
        get_sg(i + 1, yl, xr, j - 1);
        get_sg(i + 1, j + 1, xr, yr);
      }
    }
  memset(used, 0, sizeof used);
  for (int i = xl; i <= xr; i++)
    for (int j = yl; j <= yr; j++) {
      if (d[i][j] == 'L') {
        used[get_sg(xl, yl, i - 1, yr) ^ get_sg(i + 1, yl, xr, yr)] = 1;
      }
      if (d[i][j] == 'R') {
        used[get_sg(xl, yl, xr, j - 1) ^ get_sg(xl, j + 1, xr, yr)] = 1;
      }
      if (d[i][j] == 'X') {
        used[get_sg(xl, yl, i - 1, j - 1) ^ get_sg(xl, j + 1, i - 1, yr) ^
             get_sg(i + 1, yl, xr, j - 1) ^ get_sg(i + 1, j + 1, xr, yr)] = 1;
      }
    }
  for (int i = 0; i <= 16000; i++)
    if (used[i] == 0) {
      sg[xl][yl][xr][yr] = i;
      break;
    }
  return sg[xl][yl][xr][yr];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if ((i + j) % 2 == 0) d[(i + j) / 2][(i - j + m) / 2] = s[i][j];
  memset(sg, -1, sizeof sg);
  int sum = get_sg(0, 0, (n + m) / 2, (n + m) / 2);
  memset(d, 0, sizeof d);
  memset(sg, -1, sizeof sg);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if ((i + j) % 2) d[(i + j) / 2][(i - j + m) / 2] = s[i][j];
  sum ^= get_sg(0, 0, (n + m) / 2, (n + m) / 2);
  if (sum == 0)
    printf("LOSE");
  else
    printf("WIN");
}
