#include <bits/stdc++.h>
using namespace std;
const int MAX_NM = 20;
int dp[2 * MAX_NM + 2][2 * MAX_NM + 2][2 * MAX_NM + 2][2 * MAX_NM + 2];
int min_x[2], min_y[2], max_x[2], max_y[2];
char board[2 * MAX_NM + 2][2 * MAX_NM + 2];
int n, m;
int grundy(int x1, int x2, int y1, int y2) {
  int s[(MAX_NM + 5) * (MAX_NM + 5)] = {};
  if (x2 < x1 || y2 < y1) return 0;
  if (dp[x1][x2][y1][y2] != -1) return dp[x1][x2][y1][y2];
  for (int i = x1; i <= x2; i += 2) {
    for (int j = y1; j <= y2; j += 2) {
      int g = 0;
      char ch = board[i][j];
      if (ch == 'L') {
        g ^= grundy(x1, i - 2, y1, y2);
        g ^= grundy(i + 2, x2, y1, y2);
      } else if (ch == 'R') {
        g ^= grundy(x1, x2, y1, j - 2);
        g ^= grundy(x1, x2, j + 2, y2);
      } else if (ch == 'X') {
        g ^= grundy(i + 2, x2, j + 2, y2);
        g ^= grundy(i + 2, x2, y1, j - 2);
        g ^= grundy(x1, i - 2, j + 2, y2);
        g ^= grundy(x1, i - 2, y1, j - 2);
      } else {
        continue;
      }
      s[g]++;
    }
  }
  int res = 0;
  while (s[res]) res++;
  return dp[x1][x2][y1][y2] = res;
}
bool solve() {
  int res = 0;
  res ^= grundy(min_x[0], max_x[0], min_y[0], max_y[0]);
  res ^= grundy(min_x[1], max_x[1], min_y[1], max_y[1]);
  if (res == 0) return false;
  return true;
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(dp, -1, sizeof(dp));
    memset(board, 0, sizeof(board));
    max_x[0] = max_x[1] = max_y[0] = max_y[1] = 0;
    min_x[0] = min_x[1] = min_y[0] = min_y[1] = 1000;
    for (int i = 0; i < n; i++) {
      char s[MAX_NM + 5];
      scanf("%s", s);
      for (int j = 0; j < m; j++) {
        int x = i + j, y = j - i + n - 1;
        int c = (i + j) % 2;
        board[x][y] = s[j];
        min_x[c] = min(x, min_x[c]);
        min_y[c] = min(y, min_y[c]);
        max_x[c] = max(x, max_x[c]);
        max_y[c] = max(y, max_y[c]);
      }
    }
    if (solve())
      printf("WIN\n");
    else
      printf("LOSE\n");
  }
  return 0;
}
