In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statues. Each statue occupies exactly one square. A square that contains a statue cannot have anything or anyone — neither any other statues, nor Anna, nor Maria.Anna is present on the board as a figurant (she stands still and never moves), and Maria has been actively involved in the game. Her goal is — to come to Anna's square. Maria and statues move in turn, Maria moves first. During one move Maria can go to any adjacent on the side or diagonal cell in which there is no statue, or she can stay in the cell where she is. The statues during their move must go one square down simultaneously, and those statues that were in the bottom row fall from the board and are no longer appeared.At that moment, when one of the statues is in the cell in which the Maria is, the statues are declared winners. At the moment when Maria comes into the cell where Anna has been waiting, Maria is declared the winner.Obviously, nothing depends on the statues, so it all depends on Maria. Determine who will win, if Maria does not make a strategic error.

You are given the 8 strings whose length equals 8, describing the initial position on the board. The first line represents the top row of the board, the next one — for the second from the top, and so on, the last line represents the bottom row. Each character string matches a single cell board in the appropriate row, and the characters are in the same manner as that of the corresponding cell. If the cell is empty, the corresponding character is ".". If a cell has Maria, then it is represented by character "M". If a cell has Anna, it is represented by the character "A". If a cell has a statue, then the cell is represented by character "S". It is guaranteed that the last character of the first row is always "A", the first character of the last line is always "M". The remaining characters are "." or "S".

If Maria wins, print string "WIN". If the statues win, print string "LOSE".

f = []
for i in range(8):
    f.append(input())

d = [[[0 for i in range(8)] for j in range(8)] for k in range(100)]

d[0][7][0] = 1
dx = [1, 1, 1, 0, 0, -1, -1, -1, 0]
dy = [1, 0, -1, 1, -1, 1, 0, -1, 0]

ans = 'LOSE'
for i in range(99):
    for x in range(8):
        for y in range(8):
            if not d[i][x][y]:
                continue
            for j in range(9):
                nx = x + dx[j]
                ny = y + dy[j]
                if not(0 <= nx < 8 and 0 <= ny < 8):
                    continue

                valid = True
                if 0 <= nx - i < 8 and f[nx - i][ny] == 'S':
                    valid = False
                if 0 <= nx - i - 1 < 8 and f[nx - i - 1][ny] == 'S':
                    valid = False

                if not valid:
                    continue
                d[i + 1][nx][ny] = 1
                if nx == 0 and ny == 7:
                    ans = 'WIN'
print(ans)

grid = [ list(input().strip()) for r in range(8) ]
grid[0][7] = '.'
grid[7][0] = '.'
mark = [ [ False for c in range(8) ] for r in range(8) ]
mark[7][0] = True

def display_grid():
    print('\n'.join(map(lambda row: ''.join(row), grid)))
    print()

def display_mark():
    for row in mark:
        row = map(lambda a: 'X' if a else '_', row)
        print(''.join(row))
    print()

for i in range(8):
    moved = False
    new_mark = [ [ False for c in range(8) ] for r in range(8) ]
    for r in range(8):
        for c in range(8):
            if not mark[r][c]:
                continue
            for R in range(max(0, r - 1), min(r + 2, 8)):
                for C in range(max(0, c - 1), min(c + 2, 8)):
                    if grid[R][C] == 'S':
                        continue
                    if R - 1 >= 0 and grid[R - 1][C] == 'S':
                        continue
                    new_mark[R][C] = True
                    moved = True
    mark = new_mark
    grid.insert(0, 8 * [ '.' ])
    grid.pop()
    if not moved:
        break

if moved:
    print('WIN')
else:
    print('LOSE')

r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9
for i in range(0, 72, 9):
    t = set()
    for x in r:
        for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):
            if s[y] == 'T': continue
            if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)
    r = t
print('WIN' if r else 'LOSE')

# Made By Mostafa_Khaled

def play(b, x, y, c):
    if c == 9:
        return True
    if b[c][y][x] == 'S':
        return False
    dx = [-1, 1, 0, 0, 0, 1, 1, -1, -1]
    dy = [0, 0, -1, 1, 0, -1, 1, -1, 1]
    for i in range(len(dx)):
        nx = x + dx[i]
        ny = y + dy[i]
        if min(nx, ny) < 0 or max(nx, ny) >= 8: continue
        if b[c][ny][nx] != 'S' and play(b, nx, ny, c+1):
            return True
    return False

board = []
for x in range(8):
    board.append(input().strip())
B = [board]
for x in range(10):
    b = B[-1]
    b_ = b[:]
    b_[0] = b_[0][:-1] + '.'
    b_.insert(0, ".......A")
    B.append(b_[:-1])
if play(B, 0, 7, 0):
    print("WIN")
else:
    print("LOSE")

from itertools import product
from queue import Queue
BOARD_SIZE = 10
OCC, EMPTY = 1, 0
VISITED = 2
board = [input() for _ in range(8)]
graph = []
for _ in range(BOARD_SIZE):
    graph += [[[EMPTY for _ in range(BOARD_SIZE)] for _ in range(BOARD_SIZE)]]

for i, j in product(range(8), repeat = 2):
    if board[i][j] == 'S':
        graph[0][i + 1][j + 1] = OCC

for i in range(BOARD_SIZE):
    graph[0][i][0] = OCC
    graph[0][i][BOARD_SIZE - 1] = OCC
    graph[0][0][i] = OCC
    graph[0][BOARD_SIZE - 1][i] = OCC

for time in range(1, BOARD_SIZE):
    for i, j in product(range(2, 9), range(1, 9)):
        graph[time][i][j] = graph[time - 1][i - 1][j]
    for i in range(BOARD_SIZE):
        graph[time][i][0] = OCC
        graph[time][i][BOARD_SIZE - 1] = OCC
        graph[time][0][i] = OCC
        graph[time][BOARD_SIZE - 1][i] = OCC

Q = Queue()
Q.put((0, 8, 1))

pos_moves = [
    [-1, -1],
    [-1, 0],
    [-1, 1],
    [0, -1],
    [0, 0],
    [0, 1],
    [1, -1],
    [1, 0],
    [1, 1]
]

while not Q.empty():
    time, i, j = Q.get()
    if time < BOARD_SIZE - 1:
        for d in pos_moves:
            if graph[time][i + d[0]][j + d[1]] != OCC and \
                    graph[time + 1][i + d[0]][j + d[1]] == EMPTY:
                graph[time + 1][i + d[0]][j + d[1]] = VISITED
                Q.put((time + 1, i + d[0], j + d[1]))

any_pos = False

for i, j in product(range(1, 9), repeat = 2):
    if graph[BOARD_SIZE - 1][i][j] == VISITED:
        any_pos = True

# WA on some 19 test

if any_pos:
    print("WIN")
else:
    print("LOSE")

r = lambda: raw_input().strip()

def check_possibility(new_position, M):
    if len(M) == 0:
        print 'WIN'
        exit()
    candidate_moves = []
    for c in [(0,0),(-1,0),(1,0),(0,1),(0,-1),(-1,-1),(-1,1),(1,-1),(1,1)]:
        new_coord = (new_position[0]+c[0], new_position[1]+c[1])
        if 0 <= new_coord[0] <= 7 and 0 <= new_coord[1] <= 7:
            candidate_moves.append(new_coord)
    candidate_moves = [c for c in candidate_moves if c not in M.keys()]
    M = dict([[(c[0],c[1]+1),'S'] for c in M.keys() if c[1]<7])
    candidate_moves = [c for c in candidate_moves if c not in M.keys()]
    for c in candidate_moves:
        check_possibility(c, dict(M.items()))

statue_locations = {}
for i in xrange(8):
    row = list(r())
    for j in xrange(8):
        if row[j] == 'S':
            statue_locations[(j,i)] = row[j]

check_possibility((0,7), dict(statue_locations.items()))
print 'LOSE'

g = [ [raw_input() for i in range(8)] ]
for i in range(9):
    tmp = []
    tmp.append('........')
    for j in range(7):
        tmpstr = ''
        for k in range(8):
            if g[i][j][k] == 'S':
                tmpstr += 'S'
            else:
                tmpstr += '.'
        tmp.append(tmpstr)
    g.append(tmp)
dire = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)]
X, Y, STEP = 0, 1, 2
stack = [(7,0,0)]
flag = False
while len(stack):
    curr = stack.pop()
    if curr[X] == 0 and curr[Y] == 7 or curr[STEP] == 9:
        flag = True
        break
    for d in dire:
        newX = curr[X] + d[X]
        newY = curr[Y] + d[Y]
        if newX >= 0 and newX < 8 and newY >= 0 and newY < 8:
            if g[curr[STEP]][newX][newY] != 'S' and g[curr[STEP] + 1][newX][newY] != 'S':
                stack.append((newX, newY, curr[STEP] + 1))
if flag:
    print 'WIN'
else:
    print 'LOSE'
#from pprint import pprint
#pprint(g)

from ctypes import *
Dim = 8
Map = c_int * Dim * Dim
Empty = 0
A = 1
M = 2
S = 3

def pmap(m):
	print '-'*20
	for i in xrange(Dim):
		for j in xrange(Dim):
			print m[i][j],
		print

def readmap():
	# return map, without A
	m = Map()
	for i in xrange(Dim):
		s = raw_input()
		for j in xrange(Dim):
			cell = s[j]
			if cell == 'S':
				m[i][j] = S
			else:
				m[i][j] = Empty
	return m

def nextMove(m):
	# m is the map
	ss = []
	for i in xrange(Dim):
		for j in xrange(Dim):
			if m[i][j] == S:
				ss.append((i, j))
	newm = Map()
	for i, j in ss:
		try:
			newm[i+1][j] = S
		except IndexError:
			pass
	return newm

ms = []
ms.append(readmap())
for t in xrange(1, 9):
	ms.append(nextMove(ms[-1]))

def bfs(start, end, ms):
	DIR = ((0, 0), (-1, 0), (1, 0), (0, -1), (0, 1), (-1, 1), (-1, -1), (1, -1), (1, 1))
	que = [] # items: (posx, posy, t)
	que.append((start[0], start[1], 0))
	vis = set()
	while que:
		# print que
		i, j, t = que.pop()
		for di, dj in DIR:
			p = i+di, j+dj, t+1
			if p[0] >= 0 and p[0] < Dim and p[1] >= 0 and p[1] < Dim:
				# pmap(ms[t+1])
				if (p not in vis) and ms[t][p[0]][p[1]] == Empty and ms[t+1][p[0]][p[1]] == Empty:
					que.append(p)
					vis.add(p)
				if t + 1 == 8:
					return True
	return False

if bfs((Dim-1, 0), (0, Dim-1), ms):
	print 'WIN'
else:
	print 'LOSE'

def play(b, x, y, c):
    if c == 9:
        return True
    if b[c][y][x] == 'S':
        return False
    dx = [-1, 1, 0, 0, 0, 1, 1, -1, -1]
    dy = [0, 0, -1, 1, 0, -1, 1, -1, 1]
    for i in range(len(dx)):
        nx = x + dx[i]
        ny = y + dy[i]
        if min(nx, ny) < 0 or max(nx, ny) >= 8: continue
        if b[c][ny][nx] != 'S' and play(b, nx, ny, c+1):
            return True
    return False

board = []
for x in range(8):
    board.append(raw_input().strip())
B = [board]
for x in range(10):
    b = B[-1]
    b_ = b[:]
    b_[0] = b_[0][:-1] + '.'
    b_.insert(0, ".......A")
    B.append(b_[:-1])
if play(B, 0, 7, 0):
    print "WIN"
else:
    print "LOSE"

import copy
f=copy.deepcopy
def d(r,c,M):
    if r<=1 and c>= 6:
        print "WIN"
        exit()
    for t in [-1,0,1]:
        for u in [1,0,-1]:
            r2=r+t
            c2=c+u
            if e(r2,c2,M):
                M2=f(M)
                for i in range(7,-1,-1):
                    for j in range(8):
                        if M2[i][j]=='S':
                            M2[i][j]='.'
                            if i<=6:
                                M2[i+1][j]='S'
                d(r2,c2,M2)
def e(r,c,M):
    if 0<=r<8 and 0<=c<8 and M[r][c]!='S' and M[r-1][c]!='S':
        return 1
    return 0
C=[[x for x in raw_input()]for i in range(8)]
d(7,0,f(C))
print "LOSE"

from copy import deepcopy
A=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(0,0),(1,0),(0,-1),(1,-1)]
def dfs(r,c,M):
    if r<=1 and c>= 6:
        print "WIN"
        exit()
    for x in A:
        if can(r+x[0],c+x[1],M):
            M2=deepcopy(M)
            r2=r+x[0]
            c2=c+x[1]
            for i in range(7,-1,-1):
                for j in range(8):
                    if M2[i][j]=='S':
                        M2[i][j]='.'
                        if i<=6:
                            M2[i+1][j]='S'
            dfs(r2,c2,M2)
def can(r,c,M):
    if r>7 or r<0 or c>7 or c<0:
        return False
    if M[r][c]=='S' or M[r-1][c]=='S':
        return False
    return True
C=[[x for x in raw_input()]for i in range(8)]
dfs(7,0,deepcopy(C))
print "LOSE"

s=[raw_input() for i in range(8)]
d=[[16]*8 for i in range(8)]
deep=0;

def res(a):
	print ["LOSE","WIN"][a]
	exit()

def can(r,c,r1,c1):
	global d
	return r+r1>=0 and r+r1<=7 and c+c1>=0 and c+c1<=7 and (d[r+r1][c+c1]>d[r][c])

def dfs(r,c):
	global deep,d
	d[r][c]=deep;
	deep+=1

	if r==0 and c==7:
		res(1)

	sw=0
	for r1 in [-1,1,0]:
		for c1 in [1 ,-1, 0]:
			if can(r,c,r1,c1):
				sw=1

	if sw:
		for r1 in [-1,1,0]:
			for c1 in [1 ,-1, 0]:
				if can(r,c,r1,c1) or (r1==0 and c1==0):
					A=True
					for i in range(8):
						if s[i][c+c1]=='S' and (min(i+deep,7)==r+r1 or min(i+deep-1,7)==r+r1):
							A=False

					if A:
						dfs(r+r1,c+c1)
						deep-=1

dfs(7,0)
res(0)

s=[raw_input() for i in range(8)]
d=[[16]*8 for i in range(8)]
deep=0;

def res(a):
	print ["LOSE","WIN"][a]
	exit()

def dfs(r,c):
	global deep,d
	d[r][c]=deep;
	deep+=1

	if r==0 and c==7:
		maria=True
		res(True)

	C=False
	for i1 in [-1,1,0]:
		for i2 in [1 ,-1, 0]:
			if r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>d[r][c]:
				C=True

	if C:
		for i1 in [-1,1,0]:
			for i2 in [1 ,-1, 0]:
				if r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and (d[r+i1][c+i2]>=deep or (i1==0 and i2==0)):
					A=True
					for i in range(8):
						if s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep-1,7)==r+i1):
							A=False
							break

					if A:
						dfs(r+i1,c+i2)
						deep-=1

dfs(7,0)
res(False)

#Codeforces , Statues

import sys
from sys import stdin
import copy

ONLINE_JUDGE = 1

if ONLINE_JUDGE == False:
    sys.stdin = open('input.txt', 'r')

def ok(x, y):
    if x >= 0 and x < 8 and y >= 0 and y < 8:
        return True
    return False

mat = [[x for x in raw_input()] for i in range(8)]
#print type(mat)

d = [[0, 1], [0, -1], [-1, 0], [1, 0], [1, -1], [1,1], [-1, -1], [-1, 1]]
bingo = False
while True:
    tmp = copy.deepcopy(mat)
    for i in range(8):
        for j in range(8):
            if 'M' == tmp[i][j]:
                for k in range(8):
                    x = i + d[k][0]
                    y = j + d[k][1]
                    if ok(x, y) and mat[x][y] != 'S':
                        mat[x][y] = 'M'

    if('M' == mat[0][7]):
        bingo = True
        break
##    for i in range(8):
##        print mat[i]
##    print
    for i in range(7, -1, -1):
        for j in range(8):
            if 'S' == mat[i][j]:
                if i + 1 < 8:
                    mat[i + 1][j] = 'S'
                mat[i][j] = '.'
    cnt = 0
    for i in range(8):
        for j in range(8):
            if mat[i][j] == 'M':
                cnt += 1

    if 0 == cnt:
        break
if bingo:
    print 'WIN'
else:
    print 'LOSE'

#!/usr/bin/python
# coding: utf-8
import sys

lines =[l.strip() for l in sys.stdin.readlines()]
F = len(lines)
M_posi = [{'x':0, 'y':F - 1}]
nexs = []
ans = 'WIN'
#over ride G for time attack
for i in range(F):
    if 'S' not in lines[i]:
        lines[i] = 'G' * 8
    else:
        break
lines = zip(*lines)
for i in range(F):
    if 'S' not in lines[i]:
        lines[i] = 'G' * 8
lines = zip(*lines)
#run
for l_num in range(F):
    nexs = []
    #Maria move
    for posi in M_posi:
        x = posi['x']
        y = posi['y']
        for i in range(-1, 2):
            nx = x + i
            for n in range(-1, 2):
                ny = y + n
                if {'x':nx, 'y':ny} in nexs:
                    continue
                if nx < F and nx > -1 and ny < F and ny > -1:
                    if lines[ny][nx] == 'G':
                        ans = 'GET G'
                    if lines[ny][nx] != 'S':
                        nexs.append({'x':nx, 'y':ny})
    #obstacle move
    lines = lines[:-1]
    lines.insert(0, '........')
    for nex in nexs[:]:
        x = nex['x']
        y = nex['y']
        if lines[y][x] == 'S':
            posi = {'x':x, 'y':y}
            while posi in nexs: nexs.remove(posi)
    if nexs == []:
        ans = 'LOSE'
        break
    elif ans == 'GET G':
        ans = 'WIN'
        break
    M_posi = nexs[:]
print ans

from sys import stdin
from collections import *
from copy import deepcopy

def valid(i, j):
    n, m = [8] * 2
    return i > -1 and i < n and j > -1 and j < m

def str_inp(n):
    return list(reversed(list((list(stdin.readline()[:-1]) for x in range(n)))))

def check(x, y, step):
    if step + 1 < 8 and all[step + 1][x][y] == 'S' or step < 8 and all[step][x][y] == 'S':
        # print(all[step][x][y], x, y)
        return False

    return True

def print_maze(x):
    for i in range(8):
        print(*all[x][i], sep='')
    print(end='\n')

def dfs(x, y):
    stack, visit, step = [[x, y, -1]], defaultdict(int), -1

    while (stack):
        x, y, step = stack.pop()
        step += 1

        if chess[x][y] == 'A':
            exit(print('WIN'))

        st = 0

        for i in range(9):
            nx, ny = [x + dx[i], y + dy[i]]
            if i == 0:
                if step >= 8:
                    continue
                else:
                    visit[nx, ny] = 0

            if valid(nx, ny) and check(nx, ny, step) and not visit[nx, ny]:
                stack.append([nx, ny, step])
                # print(nx, ny, step, check(nx, ny, step))
                # print_maze(min(step, 7))
                visit[nx, ny] = 1
            else:
                st += 1
        # print(stack, step)
        if st == 9:
            step -= 1
            visit[x, y] = 0

dx, dy, chess = [0, -1, 0, 1, 0, 1, -1, 1, -1], [0, 0, 1, 0, -1, 1, -1, -1, 1], str_inp(8)
all, ini = [chess], [['.' for i in range(8)] for j in range(8)]

for k in range(1, 9):
    tem = deepcopy(ini)
    for i in range(8):
        for j in range(8):
            if chess[i][j] == 'S' and i - k > -1:
                tem[i - k][j] = 'S'
    all.append(tem)

dfs(0, 0)
print('LOSE')

# -*- coding: utf-8 -*-

import copy

invalid = []

def isWin(board, mi, mj, turn):
    for row in board:
        if 'S' in row:
            return False
    return True

def dfs(board, mi, mj, turn):

    if isWin(board, mi, mj, turn):
        return True
    elif (mi*100+mj*10+turn) in invalid:
        return False
    else:
        for i in range(-1, 2):
            for j in range(-1, 2):
                # Maria's turn
                if (-1 < mi+i and mi+i < 8) and (-1 < mj+j and mj+j < 8) and (board[mi+i][mj+j] != 'S'):
                    next_board = copy.deepcopy(board)
                    next_board[mi][mj] = '.'
                    # next_board[mi+i][mj+j] = 'M'

                    # Statues's turn
                    if mi+i == 0 or next_board[mi+i-1][mj+j] != 'S':
                        next_board = [['.']*8] + next_board[: -1]
                        next_board[mi+i][mj+j] = 'M'
                        if dfs(next_board, mi+i, mj+j, turn+1):
                            return True
        invalid.append(mi*100+mj*10+turn)
        return False

def main():
    board = [[cell for cell in raw_input()] for _ in range(8)]

    if dfs(board, 7, 0, 0):
        print 'WIN'
    else:
        print 'LOSE'

if __name__ == '__main__':
    main()

d = [-1, 0, 1]
s = [raw_input() for _ in range(8)]
m = [(7, 0)]
for step in range(8):
    t = []
    for x, y in m:
        for dx in d:
            for dy in d:
                tx, ty = x + dx, y + dy
                if (tx, ty) not in t:
                    if 0 <= tx < 8 and 0 <= ty < 8:
                        ok = 1
                        if tx - step >= 0: ok &= s[tx - step][ty]!='S'
                        if tx - step - 1 >= 0: ok &= s[tx - step - 1][ty]!='S'
                        if ok: t.append((tx, ty))
    m = t
print m and 'WIN' or 'LOSE'

s=[raw_input() for i in range(8)]
r=[(7,0)]
for step in range(8):
  t=[]
  for x,y in r:
    for dx in [-1,0,1]:
      for dy in [-1,0,1]:
        xx = x+dx
        yy = y+dy
        if (xx,yy) not in t:
          if 0<=xx<8 and 0<=yy<8:
            ok = True
            if xx-step>=0:
              ok &= s[xx-step][yy]!='S'
            if xx-step-1>=0:
              ok &= s[xx-step-1][yy]!='S'
            if ok:
              t.append((xx,yy))
  r=t
if r:
  print 'WIN'
else:
  print 'LOSE'

#!/usr/bin/python
# coding: utf-8
import sys

lines =[l.strip() for l in sys.stdin.readlines()]
F = len(lines)
M_posi = [{'x':0, 'y':F - 1}]
nexs = []
ans = 'WIN'
for i in range(F):
    if 'S' not in lines[i]:
        lines[i] = 'G' * 8
    else:
        break
lines = zip(*lines)
for i in range(F):
    if 'S' not in lines[i]:
        lines[i] = 'G' * 8
lines = zip(*lines)
for l_num in range(F):
    nexs = []
    #Maria move
    for posi in M_posi:
        x = posi['x']
        y = posi['y']
        for i in range(-1, 2):
            nx = x + i
            for n in range(-1, 2):
                ny = y + n
                if {'x':nx, 'y':ny} in nexs:
                    continue
                if nx < F and nx > -1 and ny < F and ny > -1:
                    if lines[ny][nx] == 'G':
                        ans = 'GET G'
                    if lines[ny][nx] != 'S':
                        nexs.append({'x':nx, 'y':ny})
    #obstacle move
    lines = lines[:-1]
    lines.insert(0, '........')
    for nex in nexs[:]:
        x = nex['x']
        y = nex['y']
        if lines[y][x] == 'S':
            posi = {'x':x, 'y':y}
            while posi in nexs: nexs.remove(posi)
    if nexs == []:
        ans = 'LOSE'
        break
    elif ans == 'GET G':
        ans = 'WIN'
        break
    M_posi = nexs[:]
print ans

d=[[1,0],[-1,0],[0,1],[0,-1],[1,1],[1,-1],[-1,1],[-1,-1],[0,0]]

l=[]
for i in range(8):
    l.append(input())

#print("l is",l)

statues=[]
statues.append([])
for i in range(8):
    for j in range(8):
        #print(l[i][j],l[i][j]=='S')
        if l[i][j]=="S":
            statues[0].append(tuple([i,j]))

for i in range(1,8):
    statues.append([])
    for statue in statues[0]:
        statues[i].append(tuple([statue[0]+i,statue[1]]))

#print(statues[0])

def possible(move_no,pos):
    global d
    global statues
    if move_no>7 or (pos[0]==0 and pos[1]==7):
        #print(move_no, pos[0],pos[1])
        return(True)

    b=False
    for di in d:
        pos[0]+=di[0]
        pos[1]+=di[1]
        if pos[0]>-1 and pos[0]<8 and pos[1]>-1 and pos[1]<8 and tuple(pos) not in statues[move_no] and tuple([pos[0]-1,pos[1]]) not in statues[move_no]:
            #print(pos)
            if(possible(move_no+1,pos)):
                b=True
                break

        pos[0]-=di[0]
        pos[1]-=di[1]
    return(b)

if(possible(0,[7,0])):
    print("WIN")
else:
    print("LOSE")

r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9
for i in range(0, 72, 9):
    t = set()
    for x in r:
        for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):
            if s[y] == 'T': continue
            if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)
    r = t
print('WIN' if r else 'LOSE')

from typing import List, Tuple

def is_row_clear(board: List[str], time: int, x: int, y: int) -> bool:
    if all(row[y] != 'S' for row in board):
        return True
    first_statue_index = [row[y] for row in board].index('S')
    if first_statue_index + time > x:
        return True
    else:
        return False

def moves(x: int, y: int) -> List[Tuple[int, int]]:
    adj = [(x - 1, y - 1), (x - 1, y), (x - 1, y + 1), (x, y - 1), (x, y + 1),
           (x + 1, y - 1), (x + 1, y), (x + 1, y + 1), (x, y)]
    return [(xo, yo) for xo, yo in adj if 0 <= xo < 8 and 0 <= yo < 8]

def solve(board: List[str]) -> str:
    stack = [(0, idx, idy) for idx, line in enumerate(board)
             for idy, sq in enumerate(line) if board[idx][idy] == 'M']
    while stack:
        time, idx, idy = stack.pop()
        if is_row_clear(board, time, idx, idy) or idx == 0:
            return 'WIN'
        for xo, yo in moves(idx, idy):
            if (
                board[xo - time][yo] != 'S' and
                board[xo - 1 - time][yo] != 'S'
            ):
                stack.append((time + 1, xo, yo))
    return 'LOSE'

board = [input() for _ in range(8)]
print(solve(board))

grid=None
gridsovertime=None
visited=None

def readInput():
	global grid
	grid = []
	for _ in range(8):
		grid.append(input())
	grid = [[(False if char=='S' else True) for char in row] for row in grid]
	return grid

def getNeighbours(pos):
	x,y,t = pos
	newposes = []
	for i in range(-1,2):
		for j in range(-1,2):
			newposes.append((x+i,y+j,t+1))
	# print(newposes, len(gridsovertime), len(gridsovertime[0]), len(gridsovertime[0][0]))
	newposes = [(x,y,t) for x,y,t in newposes if (x>=0 and y>=0 and x<8 and y<8 and gridsovertime[t][x][y] and gridsovertime[t-1][x][y])]
	return newposes

def dfs(pos):
	x,y,t = pos
	visited[t][x][y]=True
	if t==10:
		return True
	out = []
	for x,y,t in getNeighbours(pos):
		# print(x,y,t)
		if visited[t][x][y]:
			continue
		out.append(dfs((x,y,t)))
	return any(out)

def solve():
	global gridsovertime,visited
	gridsovertime = [grid]
	for _ in range(12):
		currgrid = gridsovertime[-1]
		newgrid = [[True]*8] +  currgrid[:-1]
		gridsovertime.append(newgrid)

	visited = [[[False for _ in range(8)] for _ in range(8)] for _ in range(13)]

	start = (7,0,0)
	# visited[7][0][0] = True
	return dfs(start)

def main():
	readInput()
	out = solve()
	if out:
		print("WIN")
	else:
		print("LOSE")
	pass

if __name__ == '__main__':
	main()

import sys

f = sys.stdin.read().split()
assert len(f) == 8 and len(f[0]) == 8

used = dict()

def pos(x, y, k):
    if x >= k:
        return f[x - k][y]
    else:
        return '.'

def go(x, y, k):
    if (x == 0 and y == 7) or (k >= 10):
        return True

    if (x, y, k) in used:
        return used[(x, y, k)]

    if 'S' == pos(x, y, k):
        used[(x, y, k)] = False
        return False

    result = False
    for dx in [-1, 0, 1]:
        for dy in [-1, 0, 1]:
            if 0 <= x + dx < 8 and 0 <= y + dy < 8:
                if pos(x + dx, y + dy, k) != 'S':
                    result = result or go(x + dx, y + dy, k + 1)

    used[(x, y, k)] = result
    return result

if go(7, 0, 0):
    print "WIN"
else:
    print "LOSE"

#!/usr/bin/env python
import sys

stage = []

for i in range(8):
	stage.append(list(raw_input()))

def backtrack(row, col, step, pad):
	#indent = "   " * pad + "|"
	if row > 7 - step:
		return 0
	#print indent, "at", row, col
	for dx in (-1, 0, 1):
		for dy in (-1, 0, 1):
			if row + dy in range(8) and col + dx in range(8):
				#print indent, "try", row + dy, col + dx
				if row != 0:
					if stage[row + dy][col + dx] != 'S' and stage[row + dy - 1][col + dx] != 'S':
						#print indent, "check", row + dy, col + dx
						if backtrack(row + dy - 1, col + dx, step + 1, pad + 1):
							return 1
						else:
							#print indent, "failed", row + dy, col + dx
							pass

				else:
					return 1

if backtrack(7, 0, 0, 1):
	print "WIN"
else:
	print "LOSE"

maze = []
mazes = []

dx = (-1, -1, -1,  0,  0, 0,  1,  1, 1)
dy = (-1,  0,  1, -1,  0, 1, -1,  0, 1)

flag = False

def readInput():
    for i in range(8):
        temp = raw_input()
        row = [temp[0], temp[1], temp[2], temp[3],temp[4], temp[5], temp[6], temp[7]]
        maze.append(row)

def initMazes():
    temp = [".", ".", ".", ".", ".", ".", ".", "."]
    for i in range(9):
        maze0 = []
        for row in range(8):
            maze0.append(temp[:])
        mazes.append(maze0)
    for k in range(8):
        for i in range(8):
            for j in range(8):
                mazes[k][i][j] = maze[i][j]

    for k in range(1, 8):
        for i in [7,6,5,4,3,2,1,0]:
            for j in range(8):
                if i > 0:
                    if mazes[k-1][i-1][j] == 'S':
                        mazes[k][i][j] = 'S'
                    else:
                        mazes[k][i][j] = '.'
                else:
                    mazes[k][i][j] = '.'

def printMaze(maze):
    for i in range(8):
        print(maze[i])

def dfs(x, y, step):
    xx, yy = 0, 0
    global flag
    if flag : return
    if  step >= 8:
        flag = True
        return

    for i in range(9):
        xx = x + dx[i]
        yy = y + dy[i]

        #print("!!! %d, %d, %d" %(step, xx, yy))

        if xx > 7 or xx < 0 or yy > 7 or yy < 0:
            continue
        if mazes[step + 1][xx][yy] == "S" :
            continue
        if mazes[step][xx][yy] == "S" :
            continue

        #print(" ==>  %d, %d, %d" %(step+1, xx, yy))

        dfs(xx, yy, step + 1)

    return

if __name__ == "__main__":
    readInput()
    initMazes()

    dfs(7, 0, 0)

    #for i in range(8):
    #    print("-------%d------" %i)
    #    printMaze(mazes[i])
    #    print("")

    if flag:
        print "WIN"
    else:
        print "LOSE"

F=[raw_input() for i in [0]*8]

q=[(7,0)]

for I in range(8):
    t=[]
    for i,j in q:
        for x in [-1,0,1]:
            for y in [-1,0,1]:
                X,Y=i+x,j+y
                if 0<=X<8 and 0<=Y<8 and (X,Y) not in t:
                    if F[X-I][Y] != 'S' and F[X-I-1][Y] != 'S':
                        t+=[(X,Y)]
    q=t
print "WIN" if q else "LOSE"

def readints():
  return map(int,raw_input().split())

memo=set()

def main():
  x=[raw_input() for _ in xrange(8) ]
  def f(i,j,k):
    if k>10:return True
    #print i,j,k
    g=(i,j,k)
    if g in memo:
      return False
    if not (0<=i<8 and 0<=j<8) or (0<=i-k+1<8 and x[i-k+1][j]=="S") or (0<=i-k<8 and x[i-k][j]=="S"):
      memo.add(g)
      return False
    if i==0 and j==7:
      return True
    for di in xrange(-1,2):
      for dj in xrange(-1,2):
        ni=i+di
        nj=j+dj
        if f(ni,nj,k+1):return True
    memo.add(g)
    return False
  if f(7,0,0):
    print "WIN"
  else:
    print "LOSE"

  pass

if __name__=='__main__':
  main()

'''
Created on 2011-11-17

@author: Administrator
'''
import sets
class game:
    def __init__(self):
        self.state=sets.Set()
        self.array=[];
        for i in range(0,8):
            self.array.append(raw_input())
    def outrange(self,x,y):
        if x<0:
            return True
        if x>=8:
            return True
        if y<0:
            return True
        if y>=8:
            return True
        return False
    def go(self,x,y,turn):
        t=(x,y,turn)
        if t in self.state:
            return False
        self.state.add(t)
        if turn >= 8:
            return True
        for dx in range(-1,2):
            for dy in range(-1,2):
                nx=x+dx
                ny=y+dy
                if self.outrange(nx, ny):
                    continue
                nny=ny-turn
                if self.outrange(nx, nny) == False:
                    if self.array[nny][nx] == 'S':
                        continue;
                nny=ny-turn-1
                if self.outrange(nx, nny) == False:
                    if self.array[nny][nx] == 'S':
                        continue;
                res=self.go(nx,ny,turn+1)
                if res:
                    return True
        return False
    def start(self):
        res=self.go(0,7,0)
        if res:
            print "WIN"
        else:
            print "LOSE"

if __name__ == '__main__':
    a=game()
    a.start()

f = []
for i in range(8):
    f.append(input())

d = [[[0 for i in range(8)] for j in range(8)] for k in range(100)]

d[0][7][0] = 1
dx = [1, 1, 1, 0, 0, -1, -1, -1]
dy = [1, 0, -1, 1, -1, 1, 0, -1]

ans = 'LOSE'
for i in range(99):
    for x in range(8):
        for y in range(8):
            if not d[i][x][y]:
                continue
            for j in range(8):
                nx = x + dx[j]
                ny = y + dy[j]
                if not(0 <= nx < 8 and 0 <= ny < 8):
                    continue

                valid = True
                if 0 <= nx - i < 8 and f[nx - i][ny] == 'S':
                    valid = False
                if 0 <= nx - i - 1 < 8 and f[nx - i - 1][ny] == 'S':
                    valid = False

                if not valid:
                    continue
                d[i + 1][nx][ny] = 1
                if nx == 0 and ny == 7:
                    ans = 'WIN'
print(ans)

from itertools import product
from queue import Queue
BOARD_SIZE = 10
OCC_OR_VISITED, EMPTY = 1, 0
board = [input() for _ in range(8)]
graph = []
for _ in range(BOARD_SIZE):
    graph += [[[EMPTY for _ in range(BOARD_SIZE)] for _ in range(BOARD_SIZE)]]

for i, j in product(range(8), repeat = 2):
    if board[i][j] == 'S':
        graph[0][i + 1][j + 1] = OCC_OR_VISITED

for i in range(BOARD_SIZE):
    graph[0][i][0] = OCC_OR_VISITED
    graph[0][i][BOARD_SIZE - 1] = OCC_OR_VISITED
    graph[0][0][i] = OCC_OR_VISITED
    graph[0][BOARD_SIZE - 1][i] = OCC_OR_VISITED

for time in range(1, BOARD_SIZE):
    for i, j in product(range(2, 9), range(1, 9)):
        graph[time][i][j] = graph[time - 1][i - 1][j]
    for i in range(BOARD_SIZE):
        graph[time][i][0] = OCC_OR_VISITED
        graph[time][i][BOARD_SIZE - 1] = OCC_OR_VISITED
        graph[time][0][i] = OCC_OR_VISITED
        graph[time][BOARD_SIZE - 1][i] = OCC_OR_VISITED

Q = Queue()
Q.put((0, 8, 1))

pos_moves = [
    [-1, -1],
    [-1, 0],
    [-1, 1],
    [0, -1],
    [0, 0],
    [0, 1],
    [1, -1],
    [1, 0],
    [1, 1]
]

while not Q.empty():
    time, i, j = Q.get()
    if time < BOARD_SIZE - 1:
        for d in pos_moves:
            if graph[time][i + d[0]][j + d[1]] == EMPTY and \
                    graph[time + 1][i + d[0]][j + d[1]] == EMPTY:
                graph[time + 1][i + d[0]][j + d[1]] = OCC_OR_VISITED
                Q.put((time + 1, i + d[0], j + d[1]))

any_pos = False

for i, j in product(range(1, 9), repeat = 2):
    if graph[BOARD_SIZE - 1][i][j] == OCC_OR_VISITED:
        any_pos = True

if any_pos:
    print("WIN")
else:
    print("LOSE")

g = [ [raw_input() for i in range(8)] ]
for i in range(9):
    tmp = []
    tmp.append('........')
    for j in range(7):
        tmpstr = ''
        for k in range(8):
            if g[i][j][k] == 'S':
                tmpstr += 'S'
            else:
                tmpstr += '.'
        tmp.append(tmpstr)
    g.append(tmp)
dire = [(-1, -1), (-1, 0),(-1, 1),(0, -1),(0, 1),(1, -1),(1, 0),(1, 1)]
X, Y, STEP = 0, 1, 2
stack = [(7,0,0)]
flag = False
while len(stack):
    curr = stack.pop()
    if curr[X] == 0 and curr[Y] == 7 or curr[STEP] == 9:
        flag = True
        break
    for d in dire:
        newX = curr[X] + d[X]
        newY = curr[Y] + d[Y]
        if newX >= 0 and newX < 8 and newY >= 0 and newY < 8:
            if g[curr[STEP]][newX][newY] != 'S' and g[curr[STEP] + 1][newX][newY] != 'S':
                stack.append((newX, newY, curr[STEP] + 1))
if flag:
    print 'WIN'
else:
    print 'LOSS'
#from pprint import pprint
#pprint(g)

g = [ [raw_input() for i in range(8)] ]
for i in range(9):
    tmp = []
    tmp.append('........')
    for j in range(7):
        tmpstr = ''
        for k in range(8):
            if g[i][j][k] == 'S':
                tmpstr += 'S'
            else:
                tmpstr += '.'
        tmp.append(tmpstr)
    g.append(tmp)
dire = [(-1, -1), (-1, 0),(-1, 1),(0, -1),(0, 1),(1, -1),(1, 0),(1, 1)]
X, Y, STEP = 0, 1, 2
stack = [(7,0,0)]
flag = False
while len(stack):
    curr = stack.pop()
    if curr[X] == 0 and curr[Y] == 7 or curr[STEP] == 9:
        flag = True
        break
    for d in dire:
        newX = curr[X] + d[X]
        newY = curr[Y] + d[Y]
        if newX >= 0 and newX < 8 and newY >= 0 and newY < 8:
            if g[curr[STEP]][newX][newY] != 'S' and g[curr[STEP] + 1][newX][newY] != 'S':
                stack.append((newX, newY, curr[STEP] + 1))
if flag:
    print 'WIN'
else:
    print 'LOSE'
#from pprint import pprint
#pprint(g)

def play(b, x, y, c):
    if c == 9:
        return True
    if b[c][y][x] == 'S':
        return False
    dx = [-1, 1, 0, 0, 0]
    dy = [0, 0, -1, 1, 0]
    for i in range(5):
        nx = x + dx[i]
        ny = y + dy[i]
        if min(nx, ny) < 0 or max(nx, ny) >= 8: continue
        if b[c][ny][nx] != 'S' and play(b, nx, ny, c+1):
            return True
    return False

board = []
for x in range(8):
    board.append(raw_input().strip())
B = [board]
for x in range(10):
    b = B[-1]
    b_ = b[:]
    b_[0] = b_[0][:-1] + '.'
    b_.insert(0, ".......A")
    B.append(b_[:-1])
if play(B, 0, 7, 0):
    print "WIN"
else:
    print "LOSE"

def play(b, x, y, c):
    if c == 8:
        return True
    if b[c][y][x] == 'S':
        return False
    dx = [-1, 1, 0, 0, 0]
    dy = [0, 0, -1, 1, 0]
    for i in range(5):
        nx = x + dx[i]
        ny = y + dy[i]
        if min(nx, ny) < 0 or max(nx, ny) >= 8: continue
        if b[c][ny][nx] != 'S' and play(b, nx, ny, c+1):
            return True
    return False

board = []
for x in range(8):
    board.append(raw_input().strip())
B = [board]
for x in range(10):
    b = B[-1]
    b_ = b[:]
    b_[0] = b_[0][:-1] + '.'
    b_.insert(0, ".......A")
    B.append(b_[:-1])
if play(B, 0, 7, 0):
    print "WIN"
else:
    print "LOSE"

A=[(-1,1),(-1,0),(0,1),(1,0),(0,-1),(1,-1)]
M=[]
def can(r,c):
    if r > 7 or r < 0 or c > 7 or c < 0 :
        return False
    if M[r][c]=='S' or  M[r-1][c]=='S':
        return False
    return True
M=[ [x for x in raw_input()] for i in range(8) ]
r,c=7,0
while True:
    if r<=1 and c>= 6:
        print "WIN"
        exit()
    for x in A:
        if can(r+x[0],c+x[1]):
            r+=x[0]
            c+=x[1]
            for i in range(7,-1,-1):
                for j in range(8):
                    if M[i][j]=='S':
                        M[i][j]='.'
                        if i<=6:
                            M[i+1][j]='S'
            break
    else:
        print "LOSE"
        exit()

        #~
#~
    #~

A=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(1,0),(0,-1),(1,-1)]
C=[]
def dfs(r,c,M):
    if r<=1 and c>= 6:
        print "WIN"
        exit()
    for x in A:
        if can(r+x[0],c+x[1],M):
            r+=x[0]
            c+=x[1]
            for i in range(7,-1,-1):
                for j in range(8):
                    if M[i][j]=='S':
                        M[i][j]='.'
                        if i<=6:
                            M[i+1][j]='S'
            dfs(r,c,M)
def can(r,c,M):
    if r > 7 or r < 0 or c > 7 or c < 0 :
        return False
    if M[r][c]=='S' or  M[r-1][c]=='S':
        return False
    return True
C=[ [x for x in raw_input()] for i in range(8) ]
dfs(7,0,C)
print "LOSE"

A=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(1,0),(0,-1),(1,-1)]
M=[]
def can(r,c):
    if r > 7 or r < 0 or c > 7 or c < 0 :
        return False
    if M[r][c]=='S' or  M[r-1][c]=='S':
        return False
    return True
M=[ [x for x in raw_input()] for i in range(8) ]
r,c=7,0
while True:
    if r<=1 and c>= 6:
        print "WIN"
        exit()
    for x in A:
        if can(r+x[0],c+x[1]):
            r+=x[0]
            c+=x[1]
            for i in range(7,-1,-1):
                for j in range(8):
                    if M[i][j]=='S':
                        M[i][j]='.'
                        if i<=6:
                            M[i+1][j]='S'
            break
    else:
        print "LOSE"
        exit()

        #~
#~
    #~

s=[raw_input() for i in range(8)]
m=[7,0]
maria=False
deep=0;
d=[[16]*8 for i in range(8)]

def res(a):
	print ["LOSE","WIN"][a]
	exit()
def dfs(r,c):
	global deep
	d[r][c]=deep;
	deep+=1
	#print deep,r,c

	if r==0 and c==7:
		maria=True
		res(True)

	for i1 in range(-1,2):
		for i2 in range(-1,2):
			#print "I1 : " ,i1,i2
			if i1==0 and i2==0:
				continue
			#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7   , s[r+i1][c+i2]!='S':
			if r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep  and s[r+i1][c+i2]!='S':
				A=True
				for i in range(8):
					#print "deep " ,deep,r,c,i1,i2, " i:",i
					if s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep,7)==r+i1-1):
						A=False
						break
				if A:
					return dfs(r+i1,c+i2)
					deep-=1

	return False;

dfs(7,0)

res(False)

s=[raw_input() for i in range(8)]
m=[7,0]
maria=False
deep=0;
d=[[16]*8 for i in range(8)]

def res(a):
	print ["LOSE","WIN"][a]
	exit()
def dfs(r,c):
	global deep
	d[r][c]=deep;
	deep+=1
	#print deep,r,c

	if r==0 and c==7:
		maria=True
		res(True)

	for i1 in range(-1,2):
		for i2 in range(-1,2):
			#print "I1 : " ,i1,i2
			if i1==0 and i2==0:
				continue
			#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7   , s[r+i1][c+i2]!='S'
			if r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep:
				A=True
				for i in range(8):
					print "deep " ,deep,r,c,i1,i2, " i:",i
					if s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep-1,7)==r+i1):
						A=False
						break

				if A:
					print "A" , r+i1,c+i2
					return dfs(r+i1,c+i2)
					deep-=1

	return False;

dfs(7,0)

res(False)

s=[raw_input() for i in range(8)]
m=[7,0]
maria=False
deep=0;
d=[[16]*8 for i in range(8)]

def res(a):
	print ["LOSE","WIN"][a]
	exit()
def dfs(r,c):
	global deep
	d[r][c]=deep;
	deep+=1
	#print deep,r,c

	if r==0 and c==7:
		maria=True
		res(True)

	for i1 in range(-1,2):
		for i2 in range(-1,2):
			#print "I1 : " ,i1,i2
			if i1==0 and i2==0:
				continue
			#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7   , s[r+i1][c+i2]!='S'
			if r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep  and s[r+i1][c+i2]!='S':
				A=True
				for i in range(8):
					print "deep " ,deep,r,c,i1,i2, " i:",i
					if s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep,7)==r+i1):
						A=False
						break

				if A:
					print "A"
					return dfs(r+i1,c+i2)
					deep-=1

	return False;

dfs(7,0)

res(False)

s=[raw_input() for i in range(8)]
m=[7,0]
maria=False
deep=0;
d=[[16]*8 for i in range(8)]

def res(a):
	print ["LOSE","WIN"][a]
	exit()
def dfs(r,c):
	global deep
	d[r][c]=deep;
	deep+=1
	#print deep,r,c

	if r==0 and c==7:
		maria=True
		res(True)

	for i1 in range(-1,2):
		for i2 in range(-1,2):
			#print "I1 : " ,i1,i2
			if i1==0 and i2==0:
				continue
			#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7   , s[r+i1][c+i2]!='S':
			if r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep  and s[r+i1][c+i2]!='S':
				A=True
				for i in range(8):
					#print "deep " ,deep,r,c,i1,i2, " i:",i
					if s[i+i1][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep,7)==r+i1-1):
						A=False
						break
				if A:
					return dfs(r+i1,c+i2)
					deep-=1

	return False;

dfs(7,0)

res(False)

s=[raw_input() for i in range(8)]
m=[7,0]
maria=False
deep=0;
d=[[16]*8 for i in range(8)]

def res(a):
	print ["LOSE","WIN"][a]
	exit()
def dfs(r,c):
	global deep
	d[r][c]=deep;
	deep+=1
	#print deep,r,c

	if r==0 and c==7:
		maria=True
		res(True)

	for i1 in range(-1,2):
		for i2 in range(-1,2):
			#print "I1 : " ,i1,i2
			if i1==0 and i2==0:
				continue
			#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7   , s[r+i1][c+i2]!='S'
			if r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep  and s[r+i1][c+i2]!='S':
				A=True
				for i in range(8):
					#print "deep " ,deep,r,c,i1,i2, " i:",i
					if s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep,7)==r+i1):
						A=False
						break

				if A:
					#print "A"
					return dfs(r+i1,c+i2)
					deep-=1

	return False;

dfs(7,0)

res(False)

s=[raw_input() for i in range(8)]
m=[7,0]
maria=False
deep=0;
d=[[False]*8 for i in range(8)]

def res(a):
	print ["LOSE","WIN"][a]
	exit()
def dfs(r,c):
	global deep
	d[r][c]=True;
	deep+=1

	if r==0 and c==7:
		maria=True
		res(True)

	if r>0 and ~d[r-1][c]:
		for i in range(8):
			if s[i][c]=='S' and max(i+deep,7)==r-1:
				return False
		return dfs(r-1,c)
		deep-=1

	if r>0 and c<7 and ~d[r-1][c+1]:
		for i in range(8):
			if s[i][c+1]=='S' and max(i+deep,7)==r-1:
				return False
		return dfs(r-1,c+1)
		deep-=1

	if c<7 and ~d[r][c+1]:
		for i in range(8):
			if s[i][c+1]=='S' and max(i+deep,7)==r:
				return False
		return dfs(r,c+1)
		deep-=1

	return False;

for i in range(1,8):
	if s[i][0]=='S':
		res(False)
if s[0][0]=='S':
	for i in range(1,7):
		if s[7-i][i]=='s':
			res(False)

dfs(7,0)

res(False)

s=[raw_input() for i in range(8)]
m=[7,0]
maria=False
deep=0;
d=[[16]*8 for i in range(8)]

def res(a):
	print ["LOSE","WIN"][a]
	exit()
def dfs(r,c):
	global deep
	d[r][c]=deep;
	deep+=1
	#print deep,r,c

	if r==0 and c==7:
		maria=True
		res(True)

	for i1 in range(-1,2):
		for i2 in range(-1,2):
			#print "I1 : " ,i1,i2
			if i1==0 and i2==0:
				continue
			#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7   , s[r+i1][c+i2]!='S'
			if r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep:
				A=True
				for i in range(8):
					#print "deep " ,deep,r,c,i1,i2, " i:",i
					if s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep-1,7)==r+i1):
						A=False
						break

				if A:
					#print "A" , r+i1,c+i2
					dfs(r+i1,c+i2)
					deep-=1

dfs(7,0)

res(False)

s=[raw_input() for i in range(8)]
m=[7,0]
maria=False
deep=0;
d=[[16]*8 for i in range(8)]

def res(a):
	print ["LOSE","WIN"][a]
	exit()
def dfs(r,c):
	global deep
	d[r][c]=deep;
	deep+=1
	#print deep,r,c

	if r==0 and c==7:
		maria=True
		res(True)

	for i1 in range(-1,2):
		for i2 in range(-1,2):
			#print "I1 : " ,i1,i2
			if i1==0 and i2==0:
				continue
			#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7   , s[r+i1][c+i2]!='S'
			if r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep:
				A=True
				for i in range(8):
					#print "deep " ,deep,r,c,i1,i2, " i:",i
					if s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep-1,7)==r+i1):
						A=False
						break

				if A:
					#print "A" , r+i1,c+i2
					return dfs(r+i1,c+i2)
					deep-=1

	return False;

dfs(7,0)

res(False)

#Codeforces , Statues

import sys
from sys import stdin
import copy

ONLINE_JUDGE = 1

if ONLINE_JUDGE == False:
    sys.stdin = open('input.txt', 'r')

def ok(x, y):
    if x >= 0 and x < 8 and y >= 0 and y < 8:
        return True
    return False

mat = [[x for x in raw_input()] for i in range(8)]
#print type(mat)

d = [[0, 1], [0, -1], [-1, 0], [1, 0]]
bingo = False
while True:
    tmp = copy.deepcopy(mat)
    for i in range(8):
        for j in range(8):
            if 'M' == tmp[i][j]:
                for k in range(4):
                    x = i + d[k][0]
                    y = j + d[k][1]
                    if ok(x, y) and mat[x][y] != 'S':
                        mat[x][y] = 'M'

    if('M' == mat[0][7]):
        bingo = True
        break
##    for i in range(8):
##        print mat[i]
##    print

    #tmp = mat[:]
    for i in range(6, -1, -1):
        for j in range(8):
            if 'S' == mat[i][j]:
                mat[i + 1][j] = 'S'
                mat[i][j] = '.'
    cnt = 0
    for i in range(8):
        for j in range(8):
            if mat[i][j] == 'M':
                cnt += 1

    if 0 == cnt:
        break
if bingo:
    print 'WIN'
else:
    print 'LOSE'

from sys import stdin
from collections import *
from copy import deepcopy

def valid(i, j):
    n, m = [8] * 2
    return i > -1 and i < n and j > -1 and j < m

def str_inp(n):
    return list(reversed(list((list(stdin.readline()[:-1]) for x in range(n)))))

def check(x, y, step):
    if step - 1 < 7 and all[step - 1][x][y] == 'S' or step < 8 and all[step][x][y] == 'S':
        # print(all[step][x][y])
        return False
    return True

def dfs(x, y):
    stack, visit, step = [[x, y]], defaultdict(int), 0

    while (stack):
        x, y = stack.pop()
        step += 1

        if chess[x][y] == 'A':
            exit(print('WIN'))

        if not visit[x, y]:
            # print(x, y, step)
            visit[x, y] = 1

        st = 0

        for i in range(8):
            nx, ny = [x + dx[i], y + dy[i]]

            if valid(nx, ny) and check(nx, ny, step) and not visit[nx, ny]:
                stack.append([nx, ny])
            else:
                st += 1

        if st == 8:
            step -= 1

dx, dy, chess = [-1, 0, 1, 0, 1, -1, 1, -1], [0, 1, 0, -1, 1, -1, -1, 1], str_inp(8)
all, ini = [chess], [['.' for i in range(8)] for j in range(8)]

for k in range(1, 9):
    tem = deepcopy(ini)
    for i in range(8):
        for j in range(8):
            if chess[i][j] == 'S' and i - k > -1:
                tem[i - k][j] = 'S'
    all.append(tem)

#print
# for i in range(8):
#     for j in range(8):
#         print(*all[i][j])
#     print(end='\n')

dfs(0, 0)
print('LOSE')

# -*- coding: utf-8 -*-

def main():

    board = [line for line in raw_input()]
    print board

if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-

import copy

invalid = []

def isWin(board, mi, mj, turn):
    for row in board:
        if 'S' in row:
            invalid.append(mi*100+mj*10+turn)
            return False
    return True

def isInvalid(mi, mj, turn):
    if (mi*100+mj*10+turn) in invalid:
        return True
    return False

def dfs(board, mi, mj, turn):

    # for i in range(8):
    #     print ''.join(board[i])

    if isWin(board, mi, mj, turn):
        return True
    elif isInvalid(mi, mj, turn):
        return False
    else:
        for i in range(-1, 2):
            for j in range(-1, 2):
                # Maria's turn
                if (-1 < mi+i and mi+i < 8) and (-1 < mj+j and mj+j < 8) and (board[mi+i][mj+j] != 'S'):
                    next_board = copy.deepcopy(board)
                    next_board[mi][mj] = '.'
                    # next_board[mi+i][mj+j] = 'M'

                    # Statues's turn
                    if mi+i == 0 or next_board[mi+i-1][mj+j] != 'S':
                        next_board = [['.']*8] + next_board[: -1]
                        next_board[mi+i][mj+j] = 'M'
                        if dfs(next_board, mi+i, mj+j, turn+1):
                            return True
        invalid.append(mi*100+mj*10+turn)
        return False

def main():
    board = [[cell for cell in raw_input()] for _ in range(8)]

    if dfs(board, 7, 0, 0):
        print 'WIN'
    else:
        print 'LOSE'

if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-

import copy

def isWin(board):
    for row in board:
        if 'S' in row:
            return False
    return True

def dfs(board, mi, mj):
    print '*' * 20
    for i in range(8):
        print ''.join(board[i])

    if isWin(board):
        return True
    else:
        for i in range(-1, 2):
            for j in range(-1, 2):
                # Maria's turn
                if (-1 < mi+i and mi+i < 8) and (-1 < mj+j and mj+j < 8) and (board[mi+i][mj+j] != 'S'):
                    next_board = copy.deepcopy(board)
                    next_board[mi][mj] = '.'
                    # next_board[mi+i][mj+j] = 'M'

                    # Statues's turn
                    if mi+i == 0 or next_board[mi+i-1][mj+j] != 'S':
                        next_board = [['.']*8] + next_board[: -1]
                        next_board[mi+i][mj+j] = 'M'
                        if dfs(next_board, mi+i, mj+j):
                            return True
        return False

def main():
    board = [[cell for cell in raw_input()] for _ in range(8)]

    if dfs(board, 7, 0):
        print 'WIN'
    else:
        print 'LOSE'

if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-

import copy

def isWin(board):
    for row in board:
        if 'S' in row:
            return False
    return True

def dfs(board, mi, mj):

    if isWin(board):
        return True
    else:
        for i in range(-1, 2):
            for j in range(-1, 2):
                # Maria's turn
                if (-1 < mi+i and mi+i < 8) and (-1 < mj+j and mj+j < 8) and (board[mi+i][mj+j] != 'S'):
                    next_board = copy.deepcopy(board)
                    next_board[mi][mj] = '.'
                    # next_board[mi+i][mj+j] = 'M'

                    # Statues's turn
                    if mi+i == 0 or next_board[mi+i-1][mj+j] != 'S':
                        next_board = [['.']*8] + next_board[: -1]
                        next_board[mi+i][mj+j] = 'M'
                        return dfs(next_board, mi+i, mj+j)
        return False

def main():
    board = [[cell for cell in raw_input()] for _ in range(8)]

    if dfs(board, 7, 0):
        print 'WIN'
    else:
        print 'LOSE'

if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-

def main():

    board = [raw_input() for _ in range(8)]
    print board

if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-

import copy

def isWin(board):
    for row in board:
        if 'S' in row:
            return False
    return True

def dfs(board, mi, mj):

    if isWin(board):
        return True
    else:
        for i in range(-1, 2):
            for j in range(-1, 2):
                # Maria's turn
                if (-1 < mi+i and mi+i < 8) and (-1 < mj+j and mj+j < 8) and (board[mi+i][mj+j] != 'S'):
                    next_board = copy.deepcopy(board)
                    next_board[mi+i][mj+j] = 'M'
                    next_board[mi][mj] = '.'

                    # Statues's turn
                    if next_board[mi+i-1][mj+j] != 'S':
                        next_board = next_board[0: 1] + [['.']*8] + next_board[: -1]
                        next_board[mi+i][mj+j] = 'M'
                        dfs(next_board, mi+i, mj+j)
        return False

def main():
    board = [[cell for cell in raw_input()] for _ in range(8)]

    if dfs(board, 7, 0):
        print 'WIN'
    else:
        print 'LOSE'

if __name__ == '__main__':
    main()

#!/usr/bin/python
# coding: utf-8
import sys

lines =[l.strip() for l in sys.stdin.readlines()]
M_posi = [{'x':0, 'y':len(lines) - 1}]
nexs = []
ans = 'WIN'
for l_num in range(len(lines)):
    nexs = []
    #Maria move
    for posi in M_posi:
        x = posi['x']
        y = posi['y']
        for i in range(-1, 2):
            nex_x = x + i
            for n in range(-1, 1):
                nex_y = y + n
                if nex_x < len(lines) and nex_x > -1:
                    if lines[nex_y][nex_x] != 'S':
                        nexs.append({'x':nex_x, 'y':nex_y})
    #obstacle move
    lines = lines[:-1]
    lines.insert(0, '........')
    for nex in nexs[:]:
        x = nex['x']
        y = nex['y']
        if lines[y][x] == 'S':
            posi = {'x':x, 'y':y}
            while posi in nexs: nexs.remove(posi)
    if nexs == []:
        ans = 'LOSE'
        break
    M_posi = nexs[:]
print ans

#!/usr/bin/python
# coding: utf-8
import sys

lines =[l.strip() for l in sys.stdin.readlines()]
F = len(lines)
M_posi = [{'x':0, 'y':F - 1}]
nexs = []
ans = 'WIN'
for i in range(F):
    if 'S' not in lines[i]:
        lines[i] = 'M' * 8
    else:
        break
for l_num in range(F):
    nexs = []
    #Maria move
    for posi in M_posi:
        x = posi['x']
        y = posi['y']
        for i in range(-1, 2):
            nx = x + i
            for n in range(-1, 2):
                ny = y + n
                if nx < F and nx > -1 and ny < F and ny > -1:
                    if lines[ny][nx] == 'M':
                        ans = 'GET M'
                    if lines[ny][nx] != 'S':
                        nexs.append({'x':nx, 'y':ny})
    #obstacle move
    lines = lines[:-1]
    lines.insert(0, '........')
    for nex in nexs[:]:
        x = nex['x']
        y = nex['y']
        if lines[y][x] == 'S':
            posi = {'x':x, 'y':y}
            while posi in nexs: nexs.remove(posi)
    if nexs == []:
        ans = 'LOSE'
        break
    elif ans == 'GET M':
        ans = 'WIN'
        break
    M_posi = nexs[:]
print ans
"""
for line in lines:
    print line
"""

#!/usr/bin/python
# coding: utf-8
import sys

lines =[l.strip() for l in sys.stdin.readlines()]
lines.reverse()
M_posi = [0]
nexs = []
ans = 'WIN'
for line in lines[1:]:
    for posi in M_posi:
        for i in range(-1, 2):
            nex = posi + i
            if nex < len(lines) and nex > -1:
                if line[nex] != 'S':
                    nexs.append(nex)
    if nexs == []:
        ans = 'LOSE'
        break
    M_posi = nexs[:]
    nexs = []
print ans

#!/usr/bin/python
# coding: utf-8
import sys

lines =[l.strip() for l in sys.stdin.readlines()]
F = len(lines)
M_posi = [{'x':0, 'y':F - 1}]
nexs = []
ans = 'WIN'
for i in range(F):
    if 'S' not in lines[i]:
        lines[i] = 'G' * 8
    else:
        break
lines = zip(*lines)
for i in range(F):
    if 'S' not in lines[i]:
        lines[i] = 'G' * 8
lines = zip(*lines)
for l_num in range(F):
    nexs = []
    #Maria move
    for posi in M_posi:
        x = posi['x']
        y = posi['y']
        for i in range(-1, 2):
            nx = x + i
            for n in range(-1, 2):
                ny = y + n
                if {'x':x, 'y':y} in nexs:
                    continue
                if nx < F and nx > -1 and ny < F and ny > -1:
                    if lines[ny][nx] == 'G':
                        ans = 'GET G'
                    if lines[ny][nx] != 'S':
                        nexs.append({'x':nx, 'y':ny})
    #obstacle move
    lines = lines[:-1]
    lines.insert(0, '........')
    for nex in nexs[:]:
        x = nex['x']
        y = nex['y']
        if lines[y][x] == 'S':
            posi = {'x':x, 'y':y}
            while posi in nexs: nexs.remove(posi)
    if nexs == []:
        ans = 'LOSE'
        break
    elif ans == 'GET G':
        ans = 'WIN'
        break
    M_posi = nexs[:]
print ans

#!/usr/bin/python
# coding: utf-8
import sys

lines =[l.strip() for l in sys.stdin.readlines()]
lines.reverse()
M_posi = [0]
nexs = []
ans = 'WIN'
for l_num in range(1, len(lines)):
    for posi in M_posi:
        for i in range(-1, 2):
            nex = posi + i
            if nex < len(lines) and nex > -1:
                tar_c = lines[l_num][nex]
                tar_p = lines[l_num][nex]
                if l_num + 1 <= len(lines) - 1:
                    tar_p = lines[l_num + 1][nex]
                if tar_c == tar_p != 'S':
                    nexs.append(nex)
    if nexs == []:
        ans = 'LOSE'
        break
    M_posi = nexs[:]
    nexs = []
print ans

d=[[1,0],[-1,0],[0,1],[0,-1],[1,1],[1,-1],[-1,1],[-1,-1]]

l=[]
for i in range(8):
    l.append(input())

print("l is",l)

statues=[]
statues.append([])
for i in range(8):
    for j in range(8):
        #print(l[i][j],l[i][j]=='S')
        if l[i][j]=="S":
            statues[0].append(tuple([i,j]))

for i in range(1,8):
    statues.append([])
    for statue in statues[0]:
        statues[i].append(tuple([statue[0]+i,statue[1]]))

print(statues[0])

def possible(move_no,pos):
    global d
    global statues
    if move_no>7 or (pos[0]==0 and pos[1]==7):
        print(move_no, pos[0],pos[1])
        return(True)

    b=False
    for di in d:
        pos[0]+=di[0]
        pos[1]+=di[1]
        if pos[0]>-1 and pos[0]<8 and pos[1]>-1 and pos[1]<8 and tuple(pos) not in statues[move_no] and tuple([pos[0]-1,pos[1]]) not in statues[move_no]:
            print(pos)
            if(possible(move_no+1,pos)):
                b=True
                break

        pos[0]-=di[0]
        pos[1]-=di[1]
    return(b)

if(possible(0,[7,0])):
    print("WIN")
else:
    print("LOSE")

d=[[1,0],[-1,0],[0,1],[0,-1],[1,1],[1,-1],[-1,1],[-1,-1]]

l=[]
for i in range(8):
    l.append(input())

#print("l is",l)

statues=[]
statues.append([])
for i in range(8):
    for j in range(8):
        #print(l[i][j],l[i][j]=='S')
        if l[i][j]=="S":
            statues[0].append(tuple([i,j]))

for i in range(1,8):
    statues.append([])
    for statue in statues[0]:
        statues[i].append(tuple([statue[0]+i,statue[1]]))

#print(statues[0])

def possible(move_no,pos):
    global d
    global statues
    if move_no>7 or (pos[0]==0 and pos[1]==7):
        #print(move_no, pos[0],pos[1])
        return(True)

    b=False
    for di in d:
        pos[0]+=di[0]
        pos[1]+=di[1]
        if pos[0]>-1 and pos[0]<8 and pos[1]>-1 and pos[1]<8 and tuple(pos) not in statues[move_no] and tuple([pos[0]-1,pos[1]]) not in statues[move_no]:
            #print(pos)
            if(possible(move_no+1,pos)):
                b=True
                break

        pos[0]-=di[0]
        pos[1]-=di[1]
    return(b)

if(possible(0,[7,0])):
    print("WIN")
else:
    print("LOSE")

r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9
for i in range(0, 72, 9):
    t = set()
    for x in r:
        for y in (x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):
            if s[y] == 'T': continue
            if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)
    r = t
print('WIN' if r else 'LOSE')

r, s = [63], ''.join(input() + 'S' for i in range(8)) + 'S' * 9
for i in range(0, 72, 9):
    t = set()
    for x in r:
        for y in (x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):
            if s[y] == 'S': continue
            if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)
    r = t
print('WIN' if r else 'LOSE')

import operator

d = map(list, zip(*[raw_input() for i in xrange(8)]))

#ok = True

def calc(x, before_y):
  if 'S' not in d[x] or x == 7:
    return True

  if [i for i,e in enumerate(d[x]) if e == 'S' and i >= 7 - x]:
    return False

  continuous = set((before_y, before_y+1, before_y-1)) & set([i for i,e in enumerate(d[x]) if e == 'S'])

  return reduce(operator.and_, [calc(x+1,a) for a in continuous]) if continuous else True

if  'S' not in d[0]:
  print 'WIN'
else:
  if calc(1,7):
    print 'WIN'
  else:
    print 'LOSE'

import operator

d = map(list, zip(*[raw_input() for i in xrange(8)]))

#ok = True

def calc(x, before_y):
  if 'S' not in d[x] or x == 7:
    return True

  #if [i for i,e in enumerate(d[x]) if e == 'S' and i >= 7 - x]:
  #  return False

  ss = set([i for i,e in enumerate(d[x]) if e == 'S'])

  continuous = set((before_y, before_y+1, before_y-1)) & set([i for i,e in enumerate(d[x]) if e == 'S'])
  #print continuous
  if [i for i in continuous if i >= 7 - x]:
    return False

  return reduce(operator.and_, [calc(x+1,a) for a in continuous]) if continuous else True

if  'S' not in d[0]:
  print 'WIN'
else:
  if reduce(operator.and_, [calc(1,a) for a in xrange(8)]):
    print 'WIN'
  else:
    print 'LOSE'

#!/usr/bin/env python
import sys

stage = []

for i in range(8):
	stage.append(list(raw_input()))

def backtrack(row, col):
	for dx in (-1, 0, 1):
		for dy in (-1, 0):
			if row + dy in range(8) and col + dx in range(8):
				if row != 0:
					if stage[row + dy][col + dx] != 'S' and stage[row + dy - 1][col + dx] != 'S':
						if backtrack(row + dy - 1, col + dx):
							return 1
				else:
					return 1
	return 0

if backtrack(7, 0):
	print "WIN"
else:
	print "LOSE"

def readints():
  return map(int,raw_input().split())

memo=set()

def main():
  x=[raw_input() for _ in xrange(8) ]
  def f(i,j,k):
    if k>10:return True
    #print i,j,k
    g=(i,j,k)
    if g in memo:
      return False
    if not (0<=i<8 and 0<=j<8) or (0<=i-k+1<8 and x[i-k+1][j]=="S") or (0<=i-k<8 and x[i-k][j]=="S"):
      memo.add(g)
      return False
    if i==0 and j==7:
      return True
    for dir in xrange(4):
      ni=i+[0,0,1,-1][dir]
      nj=j+[1,-1,0,0][dir]
      if f(ni,nj,k+1):return True
    memo.add(g)
    return False
  if f(7,0,0):
    print "WIN"
  else:
    print "LOSE"

  pass

if __name__=='__main__':
  main()

def readints():
  return map(int,raw_input().split())

memo=set()

def main():
  x=[raw_input() for _ in xrange(8) ]
  def f(i,j,k):
    if k>10:return True
    #print i,j,k
    g=(i,j,k)
    if g in memo:
      return False
    if not (0<=i<8 and 0<=j<8) or (0<=i-k+1<8 and x[i-k+1][j]=="S") or (0<=i-k<8 and x[i-k][j]=="S"):
      memo.add(g)
      return False
    if i==0 and j==7:
      return True
    for di in xrange(-1,2):
      for dj in xrange(-1,2):
        if di==dj==0:continue
        ni=i+di
        nj=j+dj
        if f(ni,nj,k+1):return True
    memo.add(g)
    return False
  if f(7,0,0):
    print "WIN"
  else:
    print "LOSE"

  pass

if __name__=='__main__':
  main()

'''
Created on 2011-11-17

@author: Administrator
'''
import sets
class game:
    def __init__(self):
        self.state=sets.Set()
        self.array=[];
        for i in range(0,8):
            self.array.append(raw_input())
    def outrange(self,x,y):
        if x<0:
            return True
        if x>=8:
            return True
        if y<0:
            return True
        if y>=8:
            return True
        return False
    def go(self,x,y,turn):
        t=(x,y,turn)
        if t in self.state:
            return False
        self.state.add(t)
        if turn >= 8:
            return True
        for dx in range(-1,2):
            for dy in range(-1,2):
                nx=x+dx
                ny=y+dy
                if self.outrange(nx, ny):
                    continue
                nny=ny-turn
                if self.outrange(nx, nny) != False:
                    if self.array[nny][nx] == 'S':
                        continue;
                nny=ny-turn-1
                if self.outrange(nx, nny) != False:
                    if self.array[nny][nx] == 'S':
                        continue;
                res=self.go(nx,ny,turn+1)
                if res:
                    return True
        return False
    def start(self):
        res=self.go(7,0,0)
        if res:
            print "WIN"
        else:
            print "LOSE"

if __name__ == '__main__':
    a=game()
    a.start()

'''
Created on 2011-11-17

@author: Administrator
'''
import sets
class game:
    def __init__(self):
        self.state=sets.Set()
        self.array=[];
        for i in range(0,8):
            self.array.append(raw_input())
    def outrange(self,x,y):
        if x<0:
            return True
        if x>=8:
            return True
        if y<0:
            return True
        if y>=8:
            return True
        return False
    def go(self,x,y,turn):
        t=(x,y,turn)
        if t in self.state:
            return False
        self.state.add(t)
        if turn >= 8:
            return True
        for dx in range(-1,2):
            for dy in range(-1,2):
                nx=x+dx
                ny=y+dy
                if self.outrange(nx, ny):
                    continue
                nny=ny-turn
                if self.outrange(nx, nny) != False:
                    if self.array[nny][nx] == 'S':
                        continue;
                nny=ny-turn-1
                if self.outrange(nx, nny) != False:
                    if self.array[nny][nx] == 'S':
                        continue;
                res=self.go(nx,ny,turn+1)
                if res:
                    return True
        return False
    def start(self):
        res=self.go(0,7,0)
        if res:
            print "WIN"
        else:
            print "LOSE"

if __name__ == '__main__':
    a=game()
    a.start()