Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		l := strings.Split(stdin.Text(), " ")
		if l[0] == "0" {
			break
		}
		h, _ := strconv.Atoi(l[0])
		w, _ := strconv.Atoi(l[1])

		tile := make([][]rune, h)
		done := make([][]bool, h)
		for i := 0; i < h; i++ {
			stdin.Scan()
			s := stdin.Text()
			tile[i] = make([]rune, w)
			done[i] = make([]bool, w)
			for j, c := range s {
				tile[i][j] = c
			}
		}
		i, j := 0, 0
		for tile[i][j] != '.' {
			if done[i][j] {
				i = -1
				break
			}
			done[i][j] = true
			switch tile[i][j] {
			case '>':
				j++
			case '<':
				j--
			case '^':
				i--
			case 'v':
				i++
			}
		}
		if i < 0 {
			fmt.Println("LOOP")
		} else {
			fmt.Println(j, i)
		}
	}
}

Python: H,W=1,1
while True:
    posX,posY=0,0
    H,W=map(int,input().split())
    if (H==W==0)==True:
        break
    tile=[[False for i in range(W)] for j in range(H)]
    tileinfo=[['' for i in range(W)] for j in range(H)]
    for i in range(H):
        tileinfo[i]=input().rstrip()
    while True:
        if tile[posY][posX]==True:
            print('LOOP')
            break
        else:
            tile[posY][posX]=True
        if tileinfo[posY][posX]=='>':
            posX+=1
        elif tileinfo[posY][posX]=='<':
            posX-=1
        elif tileinfo[posY][posX]=='v':
            posY+=1
        elif tileinfo[posY][posX]=='^':
            posY-=1
        elif tileinfo[posY][posX]=='.':
            print('{} {}'.format(posX,posY))
            break

Python: for a in iter(input,'0 0'):
 H,W=map(int,a.split())
 m=[input()for _ in[0]*H]
 y=x=0
 for _ in range(H*W):
  c=m[y][x]
  if'>'==c:x+=1;
  if'v'==c:y+=1;
  if'<'==c:x-=1;
  if'^'==c:y-=1;
  if'.'==c:print(x,y);break
 else:print('LOOP')

Python: import sys
from pprint import pprint
def main():
    for line in sys.stdin:
        H,W = map(int, line.split())

        if H == 0 and W == 0:
            break

        else:
            t = []
            for _ in range(H):
                t.append(list(input()))

            x,y = 0,0
            cnt = 0
            while True:
                cnt += 1
                if t[x][y] == ">":
                    y += 1
                elif t[x][y] == "v":
                    x += 1
                elif t[x][y] == "<":
                    y -= 1
                elif t[x][y] == "^":
                    x -= 1
                elif t[x][y] == ".":
                    f = 0
                    break

                if cnt > H * W:
                    f = 1
                    break
                else:
                    pass

            if f == 0:
                print(y, x)
            elif f == 1:
                print("LOOP")


if __name__ == "__main__":
    main()

Python: if __name__ == '__main__':

	while True:
		x,y = map(int,input().split())

		if x == 0 and y == 0:
			break

		A = []
		for _ in range(x):
			line = list(input())
			A.append(line)

		ans = []
		W = 0
		H = 0
		s = A[H][W]
		while True:
			if s == ">":
				W += 1
			elif s == "<":
				W -= 1
			elif s == "^":
				H -= 1
			elif s == "v":
				H += 1
			else:
				print(W,H)
				break

			s = A[H][W]
			if [H,W] in ans:
				print("LOOP")
				break
			else:
				ans.append([H,W])

Python: while True :
    H, W = map(int, input().split())
    if H == 0 and W == 0 :
        break
    
    roop = "OFF"
    Tile = [list(input()) for j in range(H)]
    cursol_H = 0
    cursol_W = 0
    roop = "OFF"
    while True :
        if Tile[cursol_H][cursol_W] == ">" :
            Tile[cursol_H][cursol_W] = "/"
            cursol_W += 1
        elif Tile[cursol_H][cursol_W] == "v" :
            Tile[cursol_H][cursol_W] = "/"
            cursol_H += 1
        elif Tile[cursol_H][cursol_W] == "<" :
            Tile[cursol_H][cursol_W] = "/"
            cursol_W -= 1
        elif Tile[cursol_H][cursol_W] == "^" :
            Tile[cursol_H][cursol_W] = "/"
            cursol_H -= 1
        elif Tile[cursol_H][cursol_W] == "/" :
            roop = "ON"
            break
        else :
            break
    
    if roop == "ON" :
        print("LOOP")
    else :
        print(cursol_W, cursol_H)

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

import sys
import os

for s in sys.stdin:
    H, W = map(int, s.split())
    if H == W == 0:
        break

    M = []
    for i in range(H):
        s = input().strip()
        M.append(s)

    is_loop = False
    x = 0
    y = 0
    walk = 0
    while True:
        mark = M[y][x]
        walk += 1
        if walk > 150:
            is_loop = True
            break

        if mark == '.':
            break

        if mark == '>':
            x += 1
        elif mark == 'v':
            y += 1
        elif mark == '^':
            y -= 1
        elif mark == '<':
            x -= 1

    if is_loop:
        print('LOOP')
    else:
        print(x, y)

Python: dp=[[""] * 100 for i in range(100)]

while(1):
    try:
        h,w = (int(x) for x in input().split())
        if w == 0:
            break
        s = ""
        x = y = 0
        ans = "LOOP"
        for i in range(0,h):
            s += input()
        for i in range(0,h):
            for j in range(0,w):
                dp[i][j] = s[i * w + j]

        while(1):
            c = dp[y][x]
            dp[y][x] = 'd'
            if(c == '>'):
                x += 1
            if(c == 'v'):
                y += 1
            if(c == '^'):
                y -= 1
            if(c == '<'):
                x -= 1
            if(c == 'd'):
                break;
            if(c == '.'):
                ans = str(x)+ ' ' + str(y)
                break
        print(ans)
    except EOFError:
        break

Python: while 1:
    H,W=map(int,input().split())
    if H==W==0:break
    maze=[]
    root=[]
    x=0
    y=0
    for i in range(H):
        maze.append(list(input()))
    while 1:
        if maze[y][x]==">":
            x+=1
        elif maze[y][x]=="<":
            x-=1
        elif maze[y][x]=="^":
            y-=1
        elif maze[y][x]=="v":
            y+=1
        else:
            print(x,y)
            break
        if x+y*W in root:
            print("LOOP")
            break
        root.append(x+y*W)

Python: posX,posY=0,0
H,W=map(int,input().split())
for i in range(H):
    spam=input().rstrip()
    for j in range(W):
        if posX==j:
            if spam[j]=='>': posX+=1
            elif spam[j]=='<': posX-=1
            elif spam[j]=='v': posY+=1
            elif spam[j]=='^': posY-=1
        else: break

Python: while True:
    h,w=map(int,input().split())
    if (h,w)==(0,0):
        break
    roop=[[False for i in range(w)]for j in range(h)]
    s=[input() for _ in range(h)]
    x,y=0,0
    jud=True
    while s[y][x]!='.':
        if roop[y][x]:
            print("LOOP")
            jud=False
            break
        roop[y][x]=True
        if s[y][x]=='>':
            x+=1
        elif s[y][x]=='<':
            x-=1
        elif s[y][x]=='v':
            y+=1
        else:
            y-=1
    if jud:
        print(x,y)

Python: def solve(IsTraveled,data,h,w):
	IsTraveled[h][w]=True
	x=data[h][w]
	if x==".":
		print(w,h)
	elif x=="^":
		if IsTraveled[h-1][w]==True:
			print("LOOP")
		else:
			solve(IsTraveled,data,h-1,w)
	elif x=="v":
		if IsTraveled[h+1][w]==True:
			print("LOOP")
		else:
			solve(IsTraveled,data,h+1,w)
	elif x==">":
		if IsTraveled[h][w+1]==True:
			print("LOOP")
		else:
			solve(IsTraveled,data,h,w+1)
	elif x=="<":
		if IsTraveled[h][w-1]==True:
			print("LOOP")
		else:
			solve(IsTraveled,data,h,w-1)

while 1:
	y=input()
	h,w=y.split()
	h,w=int(h),int(w)
	if h==0:
		break
	IsTraveled=[[False for i in range(w)] for j in range(h)]
	data=[[] for j in range(h)]
	for i in range(h):
		inputdata=input()
		for j in range(len(inputdata)):
			data[i].append(inputdata[j])
#	print(data)
	solve(IsTraveled,data,0,0)
	IsTraveled.clear()
	data.clear()