#2375 포켓몬의 세계 [part2. finding my friends]

1 s   128 MB  

Description

포켓몬 친구들은 오늘도 똘똘 뭉쳐다닌다. 그들은 $A$ 부터 $Z$ 로 총 26종류의 포켓몬 친구들이 있다. 그러나, 포켓몬 친구들은 사실, 서로 친구 인 것 처럼 보이지만, 실제로는 그렇지 않다. 같은 종류의 포켓몬 끼리만 친구가 가능하다고 생각한다. 그래서, 우리는 포켓몬 친구들이 서로에게 둘러싸여 있는지 아닌지 확인하고 싶다. 방법은 간단하다. 해당 위치의 포켓몬 부터 시작해서, 최소한 4번 이상 움직여서 자기 자리로 돌아오면 together 를, 그렇지 않으면 alone 를 출력. (단, 출발위치를 제외하고 똑같은 곳을 2번 지나가는것은 불가능하다)

적어도 한 포켓몬이 친구에게 둘러쌓여있다면, print "together"

 

(one test case, only one output)

Input

$R$ $(1 \leq R \leq 50)$

$C$ $(1 \leq C \leq 50)$

 

test cases are ended if R and C are 0

Output

if possible, print "together"

else, print "alone"

Sample Input

Sample Output

4 11
AAAAAAAAAAA
ABBBBBBBBBA
ACCCCCCCCCA
AAAAAAAAAAA
50 50
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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