#include <bits/stdc++.h>
using namespace std;
const int MAXN = 20;
const int INF = 0x3f3f3f3f;
template <class T>
void Read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = 0;
  while (c < '0' || '9' < c) {
    if (c == '-') flag = 1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (flag) x = -x;
}
int m, n;
char str[MAXN + 5][MAXN + 5];
int SG[MAXN + 5][MAXN + 5][MAXN + 5][MAXN + 5];
int row[MAXN + 5][MAXN + 5];
int col[MAXN + 5][MAXN + 5];
char G[MAXN + 5][MAXN + 5];
int dfs(int l1, int r1, int l2, int r2) {
  if (l1 > r1 || l2 > r2) return 0;
  int &ret = SG[l1][r1][l2][r2];
  if (ret != -1) return ret;
  bool vis[MAXN * MAXN + 10];
  memset(vis, 0, sizeof(vis));
  for (int i = l1; i <= r1; ++i)
    for (int j = l2; j <= r2; ++j)
      if (G[i][j]) {
        int v = 0;
        if (G[i][j] == 'L')
          v = dfs(l1, i - 1, l2, r2) ^ dfs(i + 1, r1, l2, r2);
        else if (G[i][j] == 'R')
          v = dfs(l1, r1, l2, j - 1) ^ dfs(l1, r1, j + 1, r2);
        else
          v = dfs(l1, i - 1, l2, j - 1) ^ dfs(l1, i - 1, j + 1, r2) ^
              dfs(i + 1, r1, l2, j - 1) ^ dfs(i + 1, r1, j + 1, r2);
        if (v <= m * n) vis[v] = true;
      }
  ret = 0;
  while (vis[ret]) ++ret;
  return ret;
}
int main() {
  Read(m), Read(n);
  for (int i = 1; i <= m; ++i) scanf("%s", str[i] + 1);
  int cntm, cntn;
  memset(G, 0, sizeof(G));
  cntm = cntn = 0;
  for (int len = 1; len <= m + n - 1; len += 2) {
    ++cntm;
    for (int i = max(1, len - n + 1); i <= min(m, len); ++i)
      row[i][len - i + 1] = cntm;
  }
  for (int len = m & 1 ? 1 : 2; len <= m + n - 1; len += 2) {
    ++cntn;
    for (int i = max(1, len - n + 1); i <= min(m, len); ++i)
      col[m - i + 1][len - i + 1] = cntn;
  }
  for (int i = 1; i <= m; ++i)
    for (int j = 1; j <= n; ++j)
      if ((i + j - 1) & 1) G[row[i][j]][col[i][j]] = str[i][j];
  memset(SG, -1, sizeof(SG));
  int v1 = dfs(1, cntm, 1, cntn);
  memset(G, 0, sizeof(G));
  cntm = cntn = 0;
  for (int len = 2; len <= m + n - 1; len += 2) {
    ++cntm;
    for (int i = max(1, len - n + 1); i <= min(m, len); ++i)
      row[i][len - i + 1] = cntm;
  }
  for (int len = m & 1 ? 2 : 1; len <= m + n - 1; len += 2) {
    ++cntn;
    for (int i = max(1, len - n + 1); i <= min(m, len); ++i)
      col[m - i + 1][len - i + 1] = cntn;
  }
  for (int i = 1; i <= m; ++i)
    for (int j = 1; j <= n; ++j)
      if ((i + j - 1) & 1 ^ 1) G[row[i][j]][col[i][j]] = str[i][j];
  memset(SG, -1, sizeof(SG));
  int v2 = dfs(1, cntm, 1, cntn);
  puts(v1 ^ v2 ? "WIN" : "LOSE");
}
