#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const long long ooo = 9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
const int _p = 1000 * 1000 * 1000 + 7;
const int N = 100005;
const double PI = acos(-1.0);
const double eps = 1e-9;
int o(int x) { return x % _p; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
void file_put() {
  string s = "/home/jslijin/jslijin/code/";
  freopen((s + "code.in").c_str(), "r", stdin);
  freopen((s + "code.out").c_str(), "w", stdout);
}
char s[45][45];
int sg[45][45][45][45][2], n, m, x, y, ret;
int dp(int l, int r, int u, int d, int op) {
  if (sg[l][r][u][d][op] != -1) return sg[l][r][u][d][op];
  long long tmp = 0;
  for (int i = (0); i <= (n - 1); ++i)
    for (int j = (0); j <= (m - 1); ++j) {
      int p = i + j, q = j - i + n, t;
      if (p < l || p >= r || q < u || q >= d || op != ((i + j) & 1)) continue;
      if (s[i][j] == 'L') t = dp(l, p, u, d, op) ^ dp(p + 1, r, u, d, op);
      if (s[i][j] == 'R') t = dp(l, r, u, q, op) ^ dp(l, r, q + 1, d, op);
      if (s[i][j] == 'X')
        t = dp(l, p, u, q, op) ^ dp(p + 1, r, u, q, op) ^
            dp(l, p, q + 1, d, op) ^ dp(p + 1, r, q + 1, d, op);
      tmp |= 1ll << t;
    }
  return sg[l][r][u][d][op] = __builtin_ctz(++tmp);
}
int main() {
  scanf("%d%d", &n, &m), memset(sg, -1, sizeof(sg));
  for (int i = (0); i <= (n - 1); ++i) scanf("%s", s[i]);
  ret = dp(0, n + m, 0, n + m, 0) ^ dp(0, n + m, 0, n + m, 1);
  printf("%s\n", ret ? "WIN" : "LOSE");
  return 0;
}
