#include <bits/stdc++.h>
int f[50][50][50][50], n, m, rem;
char c[100][100];
int calc(int a, int b, int x, int y) {
  bool apr[1000];
  if (f[a][b][x + 20][y + 20] > -1) return f[a][b][x + 20][y + 20];
  int i, j, k;
  if (a > b || x > y) return 0;
  memset(apr, 0, sizeof(apr));
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (i + j >= a && i + j <= b && i - j >= x && i - j <= y &&
          (i + j) % 2 == rem) {
        if (c[i][j] == 'L')
          k = calc(a, i + j - 1, x, y) ^ calc(i + j + 1, b, x, y);
        if (c[i][j] == 'R')
          k = calc(a, b, x, i - j - 1) ^ calc(a, b, i - j + 1, y);
        if (c[i][j] == 'X')
          k = calc(a, i + j - 1, x, i - j - 1) ^
              calc(a, i + j - 1, i - j + 1, y) ^
              calc(i + j + 1, b, x, i - j - 1) ^
              calc(i + j + 1, b, i - j + 1, y);
        apr[k] = true;
      }
  for (k = 0; k <= n * m + 1; k++)
    if (!apr[k]) break;
  if (k == n * m + 2) k = 0;
  f[a][b][x + 20][y + 20] = k;
  return k;
}
int main() {
  scanf("%d%d", &n, &m);
  int i, j, val1, val2;
  for (i = 1; i <= n; i++) {
    getchar();
    for (j = 1; j <= m; j++) scanf("%c", &c[i][j]);
  }
  memset(f, -1, sizeof(f));
  rem = 0;
  val1 = calc(2, n + m, 1 - m, n - 1);
  memset(f, -1, sizeof(f));
  rem = 1;
  val2 = calc(2, n + m, 1 - m, n - 1);
  val1 ^= val2;
  if (val1)
    printf("WIN\n");
  else
    printf("LOSE\n");
}
