#include <bits/stdc++.h>
long long in() {
  char ch;
  long long x = 0, f = 1;
  while (!isdigit(ch = getchar())) (ch == '-') && (f = -f);
  for (x = ch ^ 48; isdigit(ch = getchar());
       x = (x << 1) + (x << 3) + (ch ^ 48))
    ;
  return x * f;
}
const int maxn = 55;
int n, m;
int sg[maxn][maxn][maxn][maxn][2];
char mp[maxn][maxn];
bool vis[1002020];
int work(int xmin, int xmax, int ymin, int ymax, int tp) {
  if (xmin > xmax || ymin > ymax) return 0;
  int &now = sg[xmin][xmax][ymin][ymax][tp];
  if (~now) return now;
  now = 0;
  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= m; y++)
      if (((x + y) & 1) == tp) {
        int xx = x + y, yy = x - y + m;
        if (xmin <= xx && xx < xmax && ymin <= yy && yy < ymax) {
          if (mp[x][y] == 'L')
            work(xmin, xx, ymin, ymax, tp), work(xx + 1, xmax, ymin, ymax, tp);
          if (mp[x][y] == 'R')
            work(xmin, xmax, ymin, yy, tp), work(xmin, xmax, yy + 1, ymax, tp);
          if (mp[x][y] == 'X')
            work(xmin, xx, ymin, yy, tp), work(xmin, xx, yy + 1, ymax, tp),
                work(xx + 1, xmax, ymin, yy, tp),
                work(xx + 1, xmax, yy + 1, ymax, tp);
        }
      }
  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= m; y++)
      if (((x + y) & 1) == tp) {
        int xx = x + y, yy = x - y + m;
        if (xmin <= xx && xx < xmax && ymin <= yy && yy < ymax) {
          if (mp[x][y] == 'L')
            vis[sg[xmin][xx][ymin][ymax][tp] ^
                sg[xx + 1][xmax][ymin][ymax][tp]] = true;
          if (mp[x][y] == 'R')
            vis[sg[xmin][xmax][ymin][yy][tp] ^
                sg[xmin][xmax][yy + 1][ymax][tp]] = true;
          if (mp[x][y] == 'X')
            vis[sg[xmin][xx][ymin][yy][tp] ^ sg[xmin][xx][yy + 1][ymax][tp] ^
                sg[xx + 1][xmax][ymin][yy][tp] ^
                sg[xx + 1][xmax][yy + 1][ymax][tp]] = true;
        }
      }
  while (vis[now]) now++;
  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= m; y++)
      if (((x + y) & 1) == tp) {
        int xx = x + y, yy = x - y + m;
        if (xmin <= xx && xx < xmax && ymin <= yy && yy < ymax) {
          if (mp[x][y] == 'L')
            vis[sg[xmin][xx][ymin][ymax][tp] ^
                sg[xx + 1][xmax][ymin][ymax][tp]] = false;
          if (mp[x][y] == 'R')
            vis[sg[xmin][xmax][ymin][yy][tp] ^
                sg[xmin][xmax][yy + 1][ymax][tp]] = false;
          if (mp[x][y] == 'X')
            vis[sg[xmin][xx][ymin][yy][tp] ^ sg[xmin][xx][yy + 1][ymax][tp] ^
                sg[xx + 1][xmax][ymin][yy][tp] ^
                sg[xx + 1][xmax][yy + 1][ymax][tp]] = false;
        }
      }
  return now;
}
char getch() {
  char ch;
  while (!isalpha(ch = getchar()))
    ;
  return ch;
}
int main() {
  n = in(), m = in();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) mp[i][j] = getch();
  memset(sg, -1, sizeof sg);
  puts(work(2, n + m + 3, 1, n + m + 3, 0) ^ work(1, n + m + 3, 1, n + m + 3, 1)
           ? "WIN"
           : "LOSE");
  return 0;
}
