#include <bits/stdc++.h>
using namespace std;
const int N = 51;
int n, m;
int SG[N][N][N][N], id;
char a[N][N], b[N][N];
int work(int x, int y, int xx, int yy) {
  bool vis[201];
  memset(vis, 0, sizeof vis);
  if (SG[x][y][xx][yy] != -1) return SG[x][y][xx][yy];
  for (int i = x; i <= xx; ++i) {
    for (int j = y; j <= yy; ++j) {
      if (b[i][j] == 'L')
        vis[work(x, y, i - 1, yy) ^ work(i + 1, y, xx, yy)] = 1;
      if (b[i][j] == 'R')
        vis[work(x, y, xx, j - 1) ^ work(x, j + 1, xx, yy)] = 1;
      if (b[i][j] == 'X') {
        int res = 0;
        res ^= work(x, y, i - 1, j - 1);
        res ^= work(i + 1, j + 1, xx, yy);
        res ^= work(i + 1, y, xx, j - 1);
        res ^= work(x, j + 1, i - 1, yy);
        vis[res] = 1;
      }
    }
  }
  int ans = 0;
  while (vis[ans]) ++ans;
  return SG[x][y][xx][yy] = ans;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) scanf("%s", a[i] + 1);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if ((i + j) & 1) b[i + j][i - j + m] = a[i][j];
  memset(SG, -1, sizeof SG);
  int ans = work(1, 1, n + m, n + m - 1);
  memset(SG, -1, sizeof SG);
  memset(b, 0, sizeof b);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if ((i + j) % 2 == 0) b[i + j][i - j + m] = a[i][j];
  ans = ans ^ work(1, 1, n + m, n + m - 1);
  if (ans)
    printf("WIN\n");
  else
    printf("LOSE\n");
  return 0;
}
