#include <bits/stdc++.h>
using namespace std;
int read() {
  int x;
  scanf("%d", &x);
  return x;
}
int init[50][50], vis[50][50][50][50], n, m, ans;
int stx[1002333], sty[1002333], top, dou[50][50], st[1002333], S[100233];
bool pd(int a, int b, int c, int d) { return (a <= c) && (b <= d); }
int SG(int a, int b, int c, int d) {
  if (!pd(a, b, c, d)) return 0;
  if (vis[a][b][c][d] != -1) return vis[a][b][c][d];
  vis[a][b][c][d] = 0;
  int tmp;
  for (int i = a; i <= c; ++i)
    for (int j = b; j <= d; ++j) {
      tmp = 0;
      if (dou[i][j] == 2)
        tmp = SG(a, b, c, j - 1) ^ SG(a, j + 1, c, d);
      else if (dou[i][j] == 1)
        tmp = SG(a, b, i - 1, d) ^ SG(i + 1, b, c, d);
      else if (dou[i][j] == 3) {
        tmp = SG(a, b, i - 1, j - 1) ^ SG(i + 1, j + 1, c, d);
        tmp = tmp ^ SG(a, j + 1, i - 1, d) ^ SG(i + 1, b, c, j - 1);
      }
    }
  for (int i = a; i <= c; ++i)
    for (int j = b; j <= d; ++j) {
      tmp = -1;
      if (dou[i][j] == 2)
        tmp = SG(a, b, c, j - 1) ^ SG(a, j + 1, c, d);
      else if (dou[i][j] == 1)
        tmp = SG(a, b, i - 1, d) ^ SG(i + 1, b, c, d);
      else if (dou[i][j] == 3) {
        tmp = SG(a, b, i - 1, j - 1) ^ SG(i + 1, j + 1, c, d);
        tmp = tmp ^ SG(a, j + 1, i - 1, d) ^ SG(i + 1, b, c, j - 1);
      }
      if (tmp != -1) S[tmp] = 1;
    }
  while (S[vis[a][b][c][d]]) vis[a][b][c][d]++;
  for (int i = a; i <= c; ++i)
    for (int j = b; j <= d; ++j) {
      tmp = -1;
      if (dou[i][j] == 2)
        tmp = SG(a, b, c, j - 1) ^ SG(a, j + 1, c, d);
      else if (dou[i][j] == 1)
        tmp = SG(a, b, i - 1, d) ^ SG(i + 1, b, c, d);
      else if (dou[i][j] == 3) {
        tmp = SG(a, b, i - 1, j - 1) ^ SG(i + 1, j + 1, c, d);
        tmp = tmp ^ SG(a, j + 1, i - 1, d) ^ SG(i + 1, b, c, j - 1);
      }
      if (tmp != -1) S[tmp] = 0;
    }
  return vis[a][b][c][d];
}
void work() {
  memset(vis, -1, sizeof vis);
  memset(dou, 0, sizeof dou);
  char opt[40];
  top = 0;
  ans = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%s", opt + 1);
    for (int j = 1; j <= m; ++j) {
      int caonima;
      if (opt[j] == 'L') caonima = 1;
      if (opt[j] == 'R') caonima = 2;
      if (opt[j] == 'X') caonima = 3;
      init[i][j] = caonima;
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if ((i + j) & 1)
        stx[++top] = i + j, sty[top] = i - j, st[top] = init[i][j];
  int minx = 2147483640, miny = 2147483640, N = 0, M = 0;
  for (int i = 1; i <= top; ++i)
    minx = min(minx, stx[i]), miny = min(miny, sty[i]);
  for (int i = 1; i <= top; ++i)
    stx[i] = stx[i] - minx + 1, sty[i] = sty[i] - miny + 1,
    dou[stx[i]][sty[i]] = st[i], N = max(N, stx[i]), M = max(M, sty[i]);
  ans = ans ^ SG(1, 1, N, M);
  memset(vis, -1, sizeof vis);
  memset(dou, 0, sizeof dou);
  top = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (((i + j) & 1) == 0)
        stx[++top] = i + j, sty[top] = i - j, st[top] = init[i][j];
  minx = 2147483640, miny = 2147483640, N = 0, M = 0;
  for (int i = 1; i <= top; ++i)
    minx = min(minx, stx[i]), miny = min(miny, sty[i]);
  for (int i = 1; i <= top; ++i)
    stx[i] = stx[i] - minx + 1, sty[i] = sty[i] - miny + 1,
    dou[stx[i]][sty[i]] = st[i], N = max(N, stx[i]), M = max(M, sty[i]);
  ans = ans ^ SG(1, 1, N, M);
  if (ans)
    printf("WIN\n");
  else
    printf("LOSE\n");
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) work();
}
