#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const long long N = 45;
long long sg[N][N][N][N][2];
long long n, m, a[N][N], b[N][N];
char s[N][N];
long long sum[N][N];
inline int ch(char x) {
  if (x == 'L') return 1;
  if (x == 'R')
    return 2;
  else
    return 3;
}
inline long long su(long long x1, long long y11111111111111111111, long long x2,
                    long long y2) {
  return (sum[x2][y2] - (x1 > 0 ? sum[x1 - 1][y2] : 0) -
          (y11111111111111111111 > 0 ? sum[x2][y11111111111111111111 - 1] : 0) +
          (x1 > 0 && y11111111111111111111 > 0
               ? sum[x1 - 1][y11111111111111111111 - 1]
               : 0));
}
inline long long dp(long long L, long long R, long long U, long long D,
                    long long o) {
  if (D < U || R < L) return 0;
  if (sg[L][R][U][D][o] != -1) return sg[L][R][U][D][o];
  bool vis[2000] = {0};
  for (long long i = (U); i <= (D); ++i)
    for (long long j = (L); j <= (R); ++j) {
      if (b[i][j] == o) switch (a[i][j]) {
          case 0:
            break;
          case 1:
            vis[dp(L, R, U, i - 1, o) ^ dp(L, R, i + 1, D, o)] = 1;
            break;
          case 2:
            vis[dp(L, j - 1, U, D, o) ^ dp(j + 1, R, U, D, o)] = 1;
            break;
          case 3:
            vis[dp(L, j - 1, U, i - 1, o) ^ dp(L, j - 1, i + 1, D, o) ^
                dp(j + 1, R, U, i - 1, o) ^ dp(j + 1, R, i + 1, D, o)] = 1;
            break;
        }
    }
  for (long long i = (0); i <= (1999); ++i)
    if (!vis[i]) {
      return sg[L][R][U][D][o] = i;
    }
}
int main() {
  memset(sg, -1, sizeof(sg));
  n = read();
  m = read();
  for (long long i = (0); i <= (n - 1); ++i) scanf("%s", s[i]);
  for (long long i = (0); i <= (n - 1); ++i)
    for (long long j = (0); j <= (m - 1); ++j) {
      a[i + j][i - j + 20] = ch(s[i][j]);
      b[i + j][i - j + 20] = (i + j) & 1;
    }
  for (long long i = (0); i <= (40); ++i)
    for (long long j = (0); j <= (40); ++j)
      sum[i][j] = a[i][j] + (i > 0 ? sum[i - 1][j] : 0) +
                  (j > 0 ? sum[i][j - 1] : 0) -
                  (i > 0 && j > 0 ? sum[i - 1][j - 1] : 0);
  long long lbd = 0, ubd = 0, dbd = 40, rbd = 40;
  while (sum[40][lbd] == 0 && lbd < 21) lbd++;
  while (sum[40][40] - sum[40][rbd - 1] == 0 && rbd > 19) rbd--;
  while (sum[40][40] - sum[dbd - 1][40] == 0) dbd--;
  if (dp(lbd, rbd, ubd, dbd, 0) ^ dp(lbd, rbd, ubd, dbd, 1))
    puts("WIN");
  else
    puts("LOSE");
}
