Last login: Sun Aug 25 10:28:39 on ttys002
-bash: /Users/yanzhao/Library/Enthought/Canopy_32bit/User/bin/activate: No such file or directory
yans-iMac:~ yanzhao$ ls
#del.py#		Movies			VirtualBox VMs
Desktop			Music			config.log
Documents		MyProject.komodoproject	del.py
Downloads		Pictures		del.py~
Library			Public			hpy.py
yans-iMac:~ yanzhao$ cd Documents/
yans-iMac:Documents yanzhao$ ls
Aizu					cuda_5.0.36_macos-2.pkg
Aptana Rubles				del.py
Aptana Studio 3 Workspace		del.py~
C++					eclipse
Eworkspace				ipython_study
Japaness				opengl
Processing				science.txt
PythonAlgorithms			ubuntu-12.04.2-desktop-amd64.iso
QEMU					ubuntu-12.04.2-desktop-i386.iso
QtTest					unixstuff
Sale.py					workspace
Sale.py~				yan.txt
c					zhao.txt
cpp					zhao.txt~
cs248Stanford
yans-iMac:Documents yanzhao$ cd Aizu
yans-iMac:Aizu yanzhao$ ls
Solution
yans-iMac:Aizu yanzhao$ cd Solution/
yans-iMac:Solution yanzhao$ ls
0009	0010	0102	0104
yans-iMac:Solution yanzhao$ cd 0104
yans-iMac:0104 yanzhao$ ls
#s.py#	s.py	s.py~
yans-iMac:0104 yanzhao$ emacs s.py

[1]+  Stopped                 emacs s.py
yans-iMac:0104 yanzhao$ emacs s.py

import sys

def UpSolve():
    while True:
        H,W = map(int ,raw_input().split())
        if [H,W] == [0,0]:
            return
        else:
            solve(H,W)


def solve(H,W):
#    H,W = map( int,raw_input().split())                                        
#    if [H,W] == [0,0]:                                                         
#        return                                                                 
#    print H,W                                                                  
    dmap = [ [[i,j,"",False]  for i in range(W) ] for j in range(H)]
#    print dmap                                                                 
    #read data                                                                  
    for j  in range(H):
        line = raw_input()
        for i in range(W):
            dmap[j][i][2] = line[i]
#    print dmap                                                                 
#    print "########"                                                           
    #end read data                                                              
    #travel                                                                     
    tx,ty = 0,0
#    while dmap[ty][tx][3] is not True:                                         
-uu-:---F1  s.py           Top L11    (Python)----------------------------------

### FIXED CODE ###

import sys

def UpSolve():
    while True:
        H,W = map(int ,raw_input().split())
        if [H,W] == [0,0]:
            return
        else:
            solve(H,W)


def solve(H,W):
#    H,W = map( int,raw_input().split())
#    if [H,W] == [0,0]:
#        return
#    print H,W
    dmap = [ [[i,j,"",False]  for i in range(W) ] for j in range(H)]
#    print dmap
    #read data
    for j  in range(H):
        line = raw_input()
        for i in range(W):
            dmap[j][i][2] = line[i]
#    print dmap
#    print "########"
    #end read data
    #travel
    tx,ty = 0,0
#    while dmap[ty][tx][3] is not True:
    while True:
#        print tx,ty,dmap[ty][tx][2],dmap[ty][tx][3]
#        print "--"
        dmap[ty][tx][3] = True
        if dmap[ty][tx][2] == "<":
            tx -= 1
        elif dmap[ty][tx][2] == ">":
            tx += 1
        elif dmap[ty][tx][2] == "v":
            ty += 1
        elif dmap[ty][tx][2] == "^":
            ty -= 1
        elif dmap[ty][tx][2] == ".":
            print tx,ty
            return
        if dmap[ty][tx][3] is True:
            print "LOOP"
            return
    
if __name__ == "__main__":
    UpSolve()