Recently Roma has become the happy owner of a new game World of Darkraft. This game combines elements of virtually all known genres, and on one of the later stages of the game Roma faced difficulties solving a puzzle.

In this part Roma fights with a cunning enemy magician. The battle takes place on a rectangular field plaid n × m. Each cell contains one magical character: L, R or X. Initially all the squares of the field are "active".

The players, Roma and enemy magician, take turns. Roma makes the first move. During a move a player selects one of the active cells. Then depending on the image in the character in the cell one of the following actions takes place: 

  * L — magical waves radiate from the cell to the left downwards and to the right upwards along diagonal paths. All cells on the path of the waves (including the selected cell too) become inactive. The waves continue until the next inactive cell or to the edge of the field if there are no inactive cells on the way. 
  * R — the magical waves radiate to the left upwards and to the right downwards. 
  * X — the magical waves radiate in all four diagonal directions. 



If the next player cannot make a move (i.e., all cells are inactive), he loses.

Roma has been trying to defeat the computer opponent for three days but he just keeps losing. He asks you to help him and determine whether it is guaranteed that he can beat the opponent, or he will have to hack the game.

Input

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 20).

Next n lines contain m characters describing the playing field: the j-th character of the i-th line equals to the magical character of the corresponding field square.

Output

On the first line print "WIN" if Roma can win or "LOSE" if it is impossible to win considering that the opponent pays optimally.

Examples

Input

2 2
RL
LR


Output

LOSE


Input

2 2
RR
RR


Output

WIN

Note

In the first test each move makes one diagonal line of the square inactive, thus it is guaranteed that Roma loses after two moves.

There are three variants of making a move in the second test: to "finish off" the main diagonal line or any of the squares that are left. That means that after three moves the game stops and Roma wins.
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 20;
int H, W;
char board[MAX_N + 1][MAX_N + 1];
int dp[2 * MAX_N + 1][2 * MAX_N + 1][2 * MAX_N + 1][2 * MAX_N + 1][2];
int grundy(int x_min, int x_max, int y_min, int y_max, int odd) {
  int &ret = dp[x_min][x_max][y_min][y_max][odd];
  if (ret != -1) return ret;
  char vis[MAX_N * 2 + 1] = {0};
  for (int y = 0; y < H; ++y) {
    for (int x = 0; x < W; ++x) {
      if (((x + y) & 1) == odd) {
        const int x_ = y + x, y_ = y - x + W;
        if (x_min <= x_ && x_ < x_max && y_min <= y_ && y_ < y_max) {
          const char cell = board[y][x];
          int g = 0;
          if (cell == 'L') {
            g = grundy(x_min, x_, y_min, y_max, odd) ^
                grundy(x_ + 1, x_max, y_min, y_max, odd);
          }
          if (cell == 'R') {
            g = grundy(x_min, x_max, y_min, y_, odd) ^
                grundy(x_min, x_max, y_ + 1, y_max, odd);
          }
          if (cell == 'X') {
            g = grundy(x_min, x_, y_min, y_, odd) ^
                grundy(x_min, x_, y_ + 1, y_max, odd) ^
                grundy(x_ + 1, x_max, y_min, y_, odd) ^
                grundy(x_ + 1, x_max, y_ + 1, y_max, odd);
          }
          vis[g] = 1;
        }
      }
    }
  }
  while (vis[++ret])
    ;
  return ret;
}
int main() {
  scanf("%d%d", &H, &W);
  for (int i = 0; i < H; ++i) {
    scanf(" %s ", board[i]);
  }
  memset(dp, -1, sizeof(dp));
  puts(grundy(0, H + W, 0, H + W, 0) ^ grundy(0, H + W, 0, H + W, 1) ? "WIN"
                                                                     : "LOSE");
  return 0;
}
