#include <bits/stdc++.h>
const int M = 45;
int n, m, sg[M][M][M][M][2];
char s[M][M];
int get(int x1, int x2, int y1, int y2, int f) {
  if (x1 > x2 || y1 > y2) return 0;
  if (sg[x1][x2][y1][y2][f] != -1) return sg[x1][x2][y1][y2][f];
  bool vis[205] = {};
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (((i + j) & 1) == f) {
        int x = i + j, y = i - j + m;
        if (x1 <= x && x <= x2 && y1 <= y && y <= y2) {
          if (s[i][j] == 'L')
            vis[get(x1, x - 1, y1, y2, f) ^ get(x + 1, x2, y1, y2, f)] = 1;
          if (s[i][j] == 'R')
            vis[get(x1, x2, y1, y - 1, f) ^ get(x1, x2, y + 1, y2, f)] = 1;
          if (s[i][j] == 'X')
            vis[get(x1, x - 1, y1, y - 1, f) ^ get(x + 1, x2, y1, y - 1, f) ^
                get(x1, x - 1, y + 1, y2, f) ^ get(x + 1, x2, y + 1, y2, f)] =
                1;
        }
      }
  for (int i = 0;; i++)
    if (!vis[i]) return sg[x1][x2][y1][y2][f] = i;
}
int main() {
  memset(sg, -1, sizeof sg);
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  if (get(1, n + m, 1, n + m, 0) ^ get(1, n + m, 1, n + m, 1))
    puts("WIN");
  else
    puts("LOSE");
}
