#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[55][55];
int dp[55][55][55][55];
int solve(int x1, int x2, int y1, int y2) {
  if (x1 > x2 || y1 > y2) return 0;
  if (dp[x1][x2][y1][y2] != -1) return dp[x1][x2][y1][y2];
  set<int> mark;
  int k;
  mark.clear();
  for (int i = x1; i <= x2; i += 2)
    for (int j = y1; j <= y2; j += 2) {
      int g = (i - j - 1 + n) / 2, h = (i + j + 1 - n) / 2;
      if (g < 0 || g >= n || h < 0 || h >= m) continue;
      if (s[g][h] == 'L')
        k = solve(x1, i - 2, y1, y2) ^ solve(i + 2, x2, y1, y2);
      else if (s[g][h] == 'R')
        k = solve(x1, x2, y1, j - 2) ^ solve(x1, x2, j + 2, y2);
      else
        k = solve(x1, i - 2, y1, j - 2) ^ solve(x1, i - 2, j + 2, y2) ^
            solve(i + 2, x2, y1, j - 2) ^ solve(i + 2, x2, j + 2, y2);
      mark.insert(k);
    }
  k = 0;
  while (mark.find(k) != mark.end()) k++;
  dp[x1][x2][y1][y2] = k;
  return k;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  memset(dp, -1, sizeof(dp));
  int x1 = 0, x2 = n + m - 2, y1 = 0, y2 = n + m - 2;
  if (x2 % 2 != 0) x2--;
  if (n % 2 == 0) y1++;
  if (m % 2 == 0) y2--;
  int a1 = solve(x1, x2, y1, y2);
  x1 = 1, x2 = n + m - 2, y1 = 0, y2 = n + m - 2;
  if (x2 % 2 == 0) x2--;
  if (n % 2 != 0) y1++;
  if (m % 2 != 0) y2--;
  int a2 = solve(x1, x2, y1, y2);
  if (a1 ^ a2)
    printf("WIN\n");
  else
    printf("LOSE\n");
  return 0;
}
