#include <bits/stdc++.h>
using namespace std;
const int N = 22;
int n, m;
string t[N];
int BASE;
int memo[2 * N][2 * N][2 * N][2 * N];
int go(int l1, int l2, int r1, int r2) {
  if (l1 > l2 || r1 > r2) return 0;
  int &res = memo[l1][l2][r1 + BASE][r2 + BASE];
  if (res != -1) return res;
  int width = (l2 - l1 + 2) / 2, height = (r2 - r1 + 2) / 2;
  vector<bool> reach(width * height + 2, false);
  for (int l = l1; l <= l2; l += 2)
    for (int r = r1; r <= r2; r += 2) {
      int i = (l + r) / 2, j = (l - r) / 2, st;
      if (i < 0 || i >= n || j < 0 || j >= m) continue;
      if (t[i][j] == 'L') st = go(l1, l - 2, r1, r2) ^ go(l + 2, l2, r1, r2);
      if (t[i][j] == 'R') st = go(l1, l2, r1, r - 2) ^ go(l1, l2, r + 2, r2);
      if (t[i][j] == 'X')
        st = go(l1, l - 2, r1, r - 2) ^ go(l1, l - 2, r + 2, r2) ^
             go(l + 2, l2, r1, r - 2) ^ go(l + 2, l2, r + 2, r2);
      reach[st] = true;
    }
  res = 0;
  while (reach[res]) res++;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < (int)(n); i++) cin >> t[i];
  memset(memo, -1, sizeof memo);
  int g[2];
  BASE = m - 1;
  for (int odd = 0; odd < (int)(2); odd++) {
    int l1 = 0, l2 = n + m - 2, r1 = -(m - 1), r2 = n - 1;
    if ((l1 & 1) == odd) l1++;
    if ((l2 & 1) == odd) l2--;
    if ((r1 & 1) == odd) r1++;
    if ((r2 & 1) == odd) r2--;
    g[odd] = go(l1, l2, r1, r2);
  }
  int res = g[0] ^ g[1];
  cout << (res ? "WIN" : "LOSE") << endl;
  return 0;
}
