#include <bits/stdc++.h>
#pragma comment(linker, "/stack:64000000")
using namespace std;
template <typename first>
inline first abs(const first& a) {
  return a < 0 ? -a : a;
}
template <typename first>
inline first sqr(const first& a) {
  return a * a;
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;
const int N = 40 + 3;
int n, m;
char f[N][N];
int SH;
int z[N][N][N][N];
void calc(int x, int y, int mins, int maxs, int mind, int maxd,
          vector<pair<pair<int, int>, pair<int, int> > >& v) {
  int curs = x + y, curd = x - y + SH;
  if (f[x][y] == 'L') {
    v.push_back(make_pair((make_pair((mins), (curs - 2))),
                          (make_pair((mind), (maxd)))));
    v.push_back(make_pair((make_pair((curs + 2), (maxs))),
                          (make_pair((mind), (maxd)))));
  } else if (f[x][y] == 'R') {
    v.push_back(make_pair((make_pair((mins), (maxs))),
                          (make_pair((mind), (curd - 2)))));
    v.push_back(make_pair((make_pair((mins), (maxs))),
                          (make_pair((curd + 2), (maxd)))));
  } else if (f[x][y] == 'X') {
    {
      pair<int, int> psum = make_pair((mins), (curs - 2));
      pair<int, int> pdif = make_pair((mind), (curd - 2));
      v.push_back(make_pair((psum), (pdif)));
    }
    {
      pair<int, int> psum = make_pair((mins), (curs - 2));
      pair<int, int> pdif = make_pair((curd + 2), (maxd));
      v.push_back(make_pair((psum), (pdif)));
    }
    {
      pair<int, int> psum = make_pair((curs + 2), (maxs));
      pair<int, int> pdif = make_pair((mind), (curd - 2));
      v.push_back(make_pair((psum), (pdif)));
    }
    {
      pair<int, int> psum = make_pair((curs + 2), (maxs));
      pair<int, int> pdif = make_pair((curd + 2), (maxd));
      v.push_back(make_pair((psum), (pdif)));
    }
  } else
    throw;
}
int grandy(int mins, int maxs, int mind, int maxd) {
  if (mins > maxs || mind > maxd) return 0;
  int& ans = z[mins][maxs][mind][maxd];
  if (ans != -1) return ans;
  set<int> mex;
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(m); j++) {
      if (((i + j) & 1) != (mins & 1)) continue;
      if (i + j < mins || i + j > maxs) continue;
      if (i - j + SH < mind || i - j + SH > maxd) continue;
      vector<pair<pair<int, int>, pair<int, int> > > v;
      calc(i, j, mins, maxs, mind, maxd, v);
      int curxor = 0;
      for (int k = 0; k < int(int((v).size())); k++)
        curxor ^= grandy(v[k].first.first, v[k].first.second, v[k].second.first,
                         v[k].second.second);
      mex.insert(curxor);
    }
  for (int i = 0; i < int(int((mex).size()) + 1); i++)
    if (!mex.count(i)) return ans = i;
  throw;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < int(n); i++) cin >> f[i];
  int tmins[2] = {INF, INF}, tmaxs[2] = {-INF, -INF}, tmind[2] = {INF, INF},
      tmaxd[2] = {-INF, -INF};
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(m); j++) {
      tmins[(i + j) & 1] = min(tmins[(i + j) & 1], i + j);
      tmaxs[(i + j) & 1] = max(tmaxs[(i + j) & 1], i + j);
      tmind[(i - j) & 1] = min(tmind[(i - j) & 1], i - j);
      tmaxd[(i - j) & 1] = max(tmaxd[(i - j) & 1], i - j);
    }
  SH = -min(tmind[0], tmind[1]);
  memset(z, -1, sizeof(z));
  int ans = grandy(tmins[0], tmaxs[0], tmind[0] + SH, tmaxd[0] + SH);
  int ans2 = grandy(tmins[1], tmaxs[1], tmind[1] + SH, tmaxd[1] + SH);
  ans ^= ans2;
  if (ans == 0)
    puts("LOSE");
  else
    puts("WIN");
  return 0;
}
