#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
template <class S>
inline void read(S& arg) {
  cin >> arg;
}
template <class S>
inline void readA(S Lptr, S Rptr) {
  while (Lptr != Rptr) {
    read(*Lptr);
    Lptr++;
  }
}
template <class S, class... T>
inline void read(S& arg, T&... rest) {
  read(arg);
  read(rest...);
}
char delimiter = ' ';
template <class S>
inline void write(S arg) {
  cout << arg << '\n';
}
template <class S, class... T>
inline void write(S arg, T... rest) {
  cout << arg << delimiter;
  write(rest...);
}
template <class S>
inline void writeA(S Lptr, S Rptr) {
  while (Lptr != Rptr) {
    cout << *Lptr;
    Lptr++;
    if (Lptr != Rptr) cout << delimiter;
  }
  cout << '\n';
}
template <class T, class S>
inline bool smin(T& a, S b) {
  return (T)b < a ? a = b, 1 : 0;
}
template <class T, class S>
inline bool smax(T& a, S b) {
  return a < (T)b ? a = b, 1 : 0;
}
constexpr int MOD = 1e9 + 9;
constexpr int N = 23;
template <typename T>
inline T mod(T& v) {
  return v = (v % MOD + MOD) % MOD;
}
template <typename T>
inline long long dom(T v) {
  return (v % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S& l, T r) {
  return mod(l += r);
}
long long po(long long v, long long u) {
  return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1;
}
int n, m, dp[N][N][N][N];
char arr[N][N];
char a[N][N];
map<pair<int, int>, char> mp;
int acc[1000 * 1000], cnt;
inline int solve(int bt) {
  int minX = 1e9, minY = 1e9, maxX = -1e9, maxY = -1e9;
  memset(a, 0, sizeof(a)), mp.clear(), memset(dp, 0, sizeof(dp));
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)m; j++)
      if (((i + j) & 1) == bt) {
        int x = ((i + j) - bt) >> 1;
        int y = ((i - j) - bt) >> 1;
        smin(minX, x);
        smin(minY, y);
        smax(maxX, x);
        smax(maxY, y);
        mp[{x, y}] = arr[i][j];
      }
  minX--, minY--;
  for (auto e : mp) a[e.first.first - minX][e.first.second - minY] = e.second;
  maxX -= minX, maxY -= minY;
  for (int dx = 0; dx < maxX; dx++)
    for (int dy = 0; dy < maxY; dy++)
      for (int lx = 1, rx = dx + 1; rx <= maxX; lx++, rx++)
        for (int ly = 1, ry = dy + 1; ry <= maxY; ly++, ry++) {
          cnt++;
          for (int i = lx; i < (int)rx + 1; i++)
            for (int j = ly; j < (int)ry + 1; j++)
              if (a[i][j]) {
                if (a[i][j] == 'R')
                  acc[dp[lx][rx][ly][j - 1] ^ dp[lx][rx][j + 1][ry]] = cnt;
                if (a[i][j] == 'L')
                  acc[dp[lx][i - 1][ly][ry] ^ dp[i + 1][rx][ly][ry]] = cnt;
                if (a[i][j] == 'X')
                  acc[dp[lx][i - 1][ly][j - 1] ^ dp[lx][i - 1][j + 1][ry] ^
                      dp[i + 1][rx][ly][j - 1] ^ dp[i + 1][rx][j + 1][ry]] =
                      cnt;
              }
          for (int i = 0;; i++)
            if (acc[i] != cnt) {
              dp[lx][rx][ly][ry] = i;
              break;
            }
        }
  return dp[1][maxX][1][maxY];
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read(n, m);
  for (int i = 0; i < (int)n; i++) readA(arr[i], arr[i] + m);
  int res = solve(0);
  if (n > 1 || m > 1) res ^= solve(1);
  write(res ? "WIN" : "LOSE");
  return 0;
}
