#include <bits/stdc++.h>
int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.tie(0);
  unsigned n, m;
  std::cin >> n >> m;
  const unsigned maxbit = 5u;
  const unsigned maxn = 30u;
  static std::array<std::array<char, maxn>, maxn> ms;
  for (unsigned i = 0; i < n; i++)
    for (unsigned j = 0; j < m; j++) std::cin >> ms[i][j];
  std::function<unsigned(unsigned long long)> convert2 =
      [&](unsigned long long base) {
        switch (base) {
          case (1ull << 0):
            return 0;
          case (1ull << 10):
            return 10;
          case (1ull << 20):
            return 20;
          case (1ull << 30):
            return 30;
          case (1ull << 40):
            return 40;
          case (1ull << 50):
            return 50;
          case (1ull << 60):
            return 60;
          case (1ull << 1):
            return 1;
          case (1ull << 11):
            return 11;
          case (1ull << 21):
            return 21;
          case (1ull << 31):
            return 31;
          case (1ull << 41):
            return 41;
          case (1ull << 51):
            return 51;
          case (1ull << 61):
            return 61;
          case (1ull << 2):
            return 2;
          case (1ull << 12):
            return 12;
          case (1ull << 22):
            return 22;
          case (1ull << 32):
            return 32;
          case (1ull << 42):
            return 42;
          case (1ull << 52):
            return 52;
          case (1ull << 62):
            return 62;
          case (1ull << 3):
            return 3;
          case (1ull << 13):
            return 13;
          case (1ull << 23):
            return 23;
          case (1ull << 33):
            return 33;
          case (1ull << 43):
            return 43;
          case (1ull << 53):
            return 53;
          case (1ull << 63):
            return 63;
          case (1ull << 4):
            return 4;
          case (1ull << 14):
            return 14;
          case (1ull << 24):
            return 24;
          case (1ull << 34):
            return 34;
          case (1ull << 44):
            return 44;
          case (1ull << 54):
            return 54;
          case (1ull << 5):
            return 5;
          case (1ull << 15):
            return 15;
          case (1ull << 25):
            return 25;
          case (1ull << 35):
            return 35;
          case (1ull << 45):
            return 45;
          case (1ull << 55):
            return 55;
          case (1ull << 6):
            return 6;
          case (1ull << 16):
            return 16;
          case (1ull << 26):
            return 26;
          case (1ull << 36):
            return 36;
          case (1ull << 46):
            return 46;
          case (1ull << 56):
            return 56;
          case (1ull << 7):
            return 7;
          case (1ull << 17):
            return 17;
          case (1ull << 27):
            return 27;
          case (1ull << 37):
            return 37;
          case (1ull << 47):
            return 47;
          case (1ull << 57):
            return 57;
          case (1ull << 8):
            return 8;
          case (1ull << 18):
            return 18;
          case (1ull << 28):
            return 28;
          case (1ull << 38):
            return 38;
          case (1ull << 48):
            return 48;
          case (1ull << 58):
            return 58;
          case (1ull << 9):
            return 9;
          case (1ull << 19):
            return 19;
          case (1ull << 29):
            return 29;
          case (1ull << 39):
            return 39;
          case (1ull << 49):
            return 49;
          case (1ull << 59):
            return 59;
        }
        return 64;
      };
  const unsigned maxstate =
      ((2u << maxbit) * (2u << maxbit) * (2u << maxbit) * (2u << maxbit)) << 1;
  static std::array<unsigned, maxstate> mem;
  mem.fill(0xffffffffu);
  std::function<unsigned(unsigned, unsigned, unsigned, unsigned, bool)> dfs =
      [&](unsigned xl, unsigned xr, unsigned yl, unsigned yr, bool typ) {
        unsigned& ans =
            mem[(xl << ((maxbit + 1) * 0)) | (xr << ((maxbit + 1) * 1)) |
                (yl << ((maxbit + 1) * 2)) | (yr << ((maxbit + 1) * 3)) |
                ((unsigned)typ << ((maxbit + 1) * 4))];
        if (~ans) return ans;
        unsigned long long filled = 0;
        for (unsigned i = 0; i < n; i++)
          for (unsigned j = 0; j < m; j++)
            if ((i ^ j ^ typ) & 1) {
              unsigned x = i + j, y = i + m - j;
              if (xl <= x && x < xr && yl <= y && y < yr) {
                switch (ms[i][j]) {
                  case 'L':
                    filled |= 1ull << (dfs(xl, x, yl, yr, typ) ^
                                       dfs(x + 1, xr, yl, yr, typ));
                    break;
                  case 'R':
                    filled |= 1ull << (dfs(xl, xr, yl, y, typ) ^
                                       dfs(xl, xr, y + 1, yr, typ));
                    break;
                  case 'X':
                    filled |= 1ull << (dfs(xl, x, yl, y, typ) ^
                                       dfs(xl, x, y + 1, yr, typ) ^
                                       dfs(x + 1, xr, yl, y, typ) ^
                                       dfs(x + 1, xr, y + 1, yr, typ));
                    break;
                }
              }
            }
        return ans = convert2((filled + 1) & ~filled);
      };
  const std::string response[] = {"WIN", "LOSE"};
  std::cout
      << response[dfs(0, n + m, 0, n + m, 0) == dfs(0, n + m, 0, n + m, 1)]
      << std::endl;
}
