#include <bits/stdc++.h>
using namespace std;
char ar[21][21];
int n, m;
int dp[21][21][21][21];
int tmp[500];
int curtmp;
bool tmpinuse;
int doit(int y, int x, int h, int w) {
  int &res = dp[y][x][h][w];
  if (res != -1) return res;
  if (!w || !h) return 0;
  for (int i = 0; i < (h); ++i) {
    for (int j = 0; j < (w); ++j) {
      if (ar[y + i][x + j] == 'R') {
        doit(y, x, h, j);
        doit(y, x + j + 1, h, w - j - 1);
      } else if (ar[y + i][x + j] == 'L') {
        doit(y, x, i, w);
        doit(y + i + 1, x, h - i - 1, w);
      } else if (ar[y + i][x + j] == 'X') {
        doit(y, x, i, j);
        doit(y + i + 1, x, h - i - 1, j);
        doit(y, x + j + 1, i, w - j - 1);
        doit(y + i + 1, x + j + 1, h - i - 1, w - j - 1);
      } else if (ar[y + i][x + j] != 'N')
        exit(3241);
    }
  }
  ++curtmp;
  if (tmpinuse) exit(3241);
  tmpinuse = true;
  for (int i = 0; i < (h); ++i) {
    for (int j = 0; j < (w); ++j) {
      if (ar[y + i][x + j] == 'R') {
        tmp[doit(y, x, h, j) ^ doit(y, x + j + 1, h, w - j - 1)] = curtmp;
      } else if (ar[y + i][x + j] == 'L') {
        tmp[doit(y, x, i, w) ^ doit(y + i + 1, x, h - i - 1, w)] = curtmp;
      } else if (ar[y + i][x + j] == 'X') {
        tmp[doit(y, x, i, j) ^ doit(y + i + 1, x, h - i - 1, j) ^
            doit(y, x + j + 1, i, w - j - 1) ^
            doit(y + i + 1, x + j + 1, h - i - 1, w - j - 1)] = curtmp;
      } else if (ar[y + i][x + j] != 'N')
        exit(3241);
    }
  }
  res = 0;
  while (tmp[res] == curtmp) ++res;
  tmpinuse = false;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  if (N == 1 && M == 1) {
    cout << "WIN";
    exit(0);
  }
  string src[30];
  for (int i = 0; i < (N); ++i) {
    cin >> src[i];
  }
  int res = 0;
  for (int qq = 0; qq < (2); ++qq) {
    n = m = (N + M - 2) / 2 + 1;
    memset(ar, 'N', sizeof(ar));
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < (N); ++i) {
      for (int j = 0; j < (M); ++j) {
        if ((i + j) % 2 != qq) continue;
        ar[(i + j - qq) / 2][(i - j + M - 1) / 2] = src[i][j];
      }
    }
    res ^= doit(0, 0, n, m);
  }
  if (res)
    cout << "WIN";
  else
    cout << "LOSE";
  return 0;
}
