#include <bits/stdc++.h>
using namespace std;
bool OK(char c) { return c == 'L' || c == 'R' || c == 'X'; }
int M, N;
char S[20][20];
int DP[40][40][40][40];
bool Flag[40][40][40][40];
int Solve(int A0, int A1, int B0, int B1, int T) {
  if (A0 > A1 || B0 > B1) return 0;
  if (Flag[A0][A1][B0 + 19][B1 + 19]) return DP[A0][A1][B0 + 19][B1 + 19];
  set<int> All;
  All.clear();
  for (int i = 0; i < M; i++) {
    int Start = max(max(A0 - i, i - B1), 0);
    int End = min(min(A1 - i, i - B0), N - 1);
    for (int j = Start; j <= End; j++) {
      if ((i ^ j ^ T) & 1) continue;
      int Temp = 0;
      if (S[i][j] == 'L') {
        Temp ^= Solve(A0, i + j - 1, B0, B1, T);
        Temp ^= Solve(i + j + 1, A1, B0, B1, T);
      } else if (S[i][j] == 'R') {
        Temp ^= Solve(A0, A1, B0, i - j - 1, T);
        Temp ^= Solve(A0, A1, i - j + 1, B1, T);
      } else {
        Temp ^= Solve(A0, i + j - 1, B0, i - j - 1, T);
        Temp ^= Solve(A0, i + j - 1, i - j + 1, B1, T);
        Temp ^= Solve(i + j + 1, A1, B0, i - j - 1, T);
        Temp ^= Solve(i + j + 1, A1, i - j + 1, B1, T);
      }
      All.insert(Temp);
    }
  }
  int Ans = 0;
  while (All.count(Ans)) Ans++;
  Flag[A0][A1][B0 + 19][B1 + 19] = true;
  return DP[A0][A1][B0 + 19][B1 + 19] = Ans;
}
int main() {
  scanf("%d%d", &M, &N);
  for (int i = 0; i < M; i++)
    for (int j = 0; j < N; j++)
      while (S[i][j] = getchar(), !OK(S[i][j]))
        ;
  int Ans = 0;
  memset(Flag, 0, sizeof(Flag));
  Ans ^= Solve(0, M + N - 2, 1 - N, M - 1, 0);
  memset(Flag, 0, sizeof(Flag));
  Ans ^= Solve(0, M + N - 2, 1 - N, M - 1, 1);
  printf(Ans ? "WIN\n" : "LOSE\n");
  return 0;
}
