#include <bits/stdc++.h>
using namespace std;
const int maxN = 42;
const int inf = 2147483647;
int n, m;
char s[maxN][maxN];
int sg[maxN][maxN][maxN][maxN], l, r, u, d, ox[maxN][maxN], oy[maxN][maxN];
bool can[maxN][maxN], al[maxN][maxN][maxN][maxN];
void init() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
}
int f(int l, int r, int d, int u) {
  if (r < l || u < d) return 0;
  if (l == r && d == u) return can[l][d];
  if (al[l][r][d][u]) return sg[l][r][d][u];
  al[l][r][d][u] = 1;
  vector<int> a;
  int x, y, p;
  for (int i = l; i <= r; ++i)
    for (int j = d; j <= u; ++j)
      if (can[i][j]) {
        x = ox[i][j];
        y = oy[i][j];
        if (s[x][y] == 'L')
          p = f(l, i - 1, d, u) ^ f(i + 1, r, d, u);
        else if (s[x][y] == 'R')
          p = f(l, r, d, j - 1) ^ f(l, r, j + 1, u);
        else {
          p = f(l, i - 1, d, j - 1);
          p ^= f(i + 1, r, d, j - 1);
          p ^= f(l, i - 1, j + 1, u);
          p ^= f(i + 1, r, j + 1, u);
        }
        a.push_back(p);
      }
  sort(a.begin(), a.end());
  p = 0;
  for (int i = 0; i < a.size(); ++i) {
    if (i != 0 && a[i] == a[i - 1]) continue;
    if (a[i] != p) return sg[l][r][d][u] = p;
    ++p;
  }
  return sg[l][r][d][u] = p;
}
int getSG(int l, int r, int d, int u) {
  int xx, yy;
  for (int a = l, x = 1; a <= r; a += 2, ++x)
    for (int b = d, y = 1; b <= u; b += 2, ++y) {
      xx = (a + b) / 2;
      yy = (a - b) / 2;
      ox[x][y] = xx;
      oy[x][y] = yy;
      if (xx < 1 || xx > n || yy < 1 || yy > m)
        can[x][y] = 0;
      else
        can[x][y] = 1;
    }
  return f(1, (r - l) / 2 + 1, 1, (u - d) / 2 + 1);
}
void work() {
  int ans = 0, x, y;
  l = inf;
  r = -inf;
  d = inf;
  u = -inf;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (((i + j) & 1) == 1) {
        l = ((i + j) < (l) ? (i + j) : (l));
        r = ((i + j) > (r) ? (i + j) : (r));
        d = ((i - j) < (d) ? (i - j) : (d));
        u = ((i - j) > (u) ? (i - j) : (u));
      }
  ans ^= getSG(l, r, d, u);
  memset(al, 0, sizeof(al));
  l = inf;
  r = -inf;
  d = inf;
  u = -inf;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (((i + j) & 1) == 0) {
        l = ((i + j) < (l) ? (i + j) : (l));
        r = ((i + j) > (r) ? (i + j) : (r));
        d = ((i - j) < (d) ? (i - j) : (d));
        u = ((i - j) > (u) ? (i - j) : (u));
      }
  ans ^= getSG(l, r, d, u);
  if (!ans)
    puts("LOSE");
  else
    puts("WIN");
}
int main() {
  init();
  work();
  return 0;
}
