Messy Kevin VI


Submit solution

Points: 1
Time limit: 1.0s
Python 2.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C++, Java, Python

With no more job, Kevin has a lot of free time. He could start searching for jobs, but he wants to relax for a bit. Since he was always in the office trying to fix his mess-ups, he hasn't gone outside in a while and for once, missed touching grass.

He goes outside to the local park and wants to walk across it from one side to the other, which we can represent as an $n \times m$ grid. He starts at the top-left of the grid and tries to get to the bottom-right, being able to move left, right, up, and down. However, there are patches of mud and dirt which he wants to avoid, because it would get his shoes all dirty. Can you help Kevin cross the park without messing his shoes?

Input

The first line contains two integers, n and m (1 \leq n,m \leq 1000), the height and width of the park.

The next n lines contain m characters. An asterisk * represents an obstacle, while . represents a patch of grass that Kevin can walk on.

Output

Output "SUCCESS" if Kevin is able to cross the park while avoiding obstacles. If not, output "FAIL".

Example

Input 1
3 4
.*..
..**
*...
Output 1
SUCCESS
Input 2
3 4
.*..
.***
*...
Output 2
FAIL

Comments

There are no comments at the moment.