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: while True:
    HW = list(map(int, input().split()))
    H, W = HW[0], HW[1]
    if H == 0 and W == 0:
        break

    tiles = [input() for i in range(H)]
    i, j, count = 0, 0, 0
    while True:
        tile = tiles[i][j]
        if count >= H*W:
            print("LOOP")
            break

        if tile == ">":
            if W > j:
                j += 1
            else:
                print(j, i)
                break

        elif tile == "<":
            if j > 0:
                j -= 1
            else:
                print(j, i)
                break

        elif tile == "^":
            if i > 0:
                i -= 1
            else:
                print(j, i)
                break

        elif tile == "v":
            if H > i:
                i += 1
            else:
                print(j, i)
                break
        else:
            print(j, i)
            break
        count += 1

Python: import sys
readline = sys.stdin.readline
write = sys.stdout.write

dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
df = "<^>v".find

def solve():
    H, W = map(int, readline().split())
    if H == 0:
        return False
    MP = [readline().strip() for i in range(H)]
    x = y = 0
    used = [[0]*W for i in range(H)]
    used[0][0] = 1
    while 1:
        i = df(MP[y][x])
        if i == -1:
            write("%d %d\n" % (x, y))
            return True
        dx, dy = dd[i]
        x += dx; y += dy
        if used[y][x]:
            write("LOOP\n")
            return True
        used[y][x] = 1
while solve():
    ...

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

while 1:
	x=input()
	h,w=x.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 i in range(w)] for j in range(h)]
	for i in range(h):
		inputdata=input()
		for j in range(len(inputdata)):
			data[i].append(inputdata[j])
	judge(IsTraveled,data,0,0)
	del IsTraveled
	del data

Python: while True:
    h, w = map(int, input().split())
    if h == w == 0:
        break
    maze = [input() for i in range(h)]
    now_x = now_y = 0
    is_used = [[False for j in range(w)] for i in range(h)]
    is_used[0][0] = True

    while True:
        now = maze[now_y][now_x]
        if now == '>':
            now_x += 1
        elif now == '<':
            now_x -= 1
        elif now == 'v':
            now_y += 1
        elif now == '^':
            now_y -= 1
        else:
            print(now_x, now_y)
            break
        if is_used[now_y][now_x]:
            print("LOOP")
            break
        is_used[now_y][now_x] = True

Python: M = ['^','<','v','>']

while True:
    n = list(map(int,input().split()))
    if n == [0,0]:
        break
    D = {}
    for r in range(n[0]):
        s = 0
        C = input()
        for c in C:
            D[(r,s)] = [c,0]
            s += 1
    now = [0,0]
    while True:
        if D[tuple(now)][1] == 0:
            D[tuple(now)][1] += 1
            if D[tuple(now)][0] == '.':
                now.reverse()
                break
            else:
                m = M.index(D[tuple(now)][0])
                now[m%2] += (m//2)*2-1
        else:
            now = ['LOOP']
            break
    print (' '.join(list(map(str,now))))

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])
	solve(IsTraveled,data,0,0)
	IsTraveled.clear()
	data.clear()

Python: DIR = {">": (0, 1), "<": (0, -1), "^": (-1, 0), "v": (1, 0)}

while True:
    w, h = map(int, raw_input().split())
    if w == 0 and h == 0:
        break

    m = []
    for i in range(w):
        m.append([c for c in raw_input().strip()])

    x = 0
    y = 0
    while m[x][y] != '.':
        i = m[x][y]
        if i == 'x':
            break
        m[x][y] = 'x'
        x += DIR[i][0]
        y += DIR[i][1]

    if m[x][y] == '.':
        print("{} {}".format(y, x))
    else:
        print("LOOP")

Python: posX,posY=0,0
H,W=map(int,input().split())
while not(H==W==0):
    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 tileinfo[posX][posY]=='>': posX+=1
        elif tileinfo[posX][posY]=='<': posX-=1
        elif tileinfo[posX][posY]=='v':
            posY+=1
            break
        elif tileinfo[posX][posY]=='^':
            posY-=1
            break
        elif spam[j]=='.': break
        if tile[posX][posY]==True:
            print('LOOP')
            break
        else:
            tile[posX][posY]=True

Python: def move(Tiles_map, x, y, Loop_ch):
    if [x,y] in Loop_ch:
        print("LOOP")
        return
    else:
        Loop_ch.append([x,y])

    if Tile_map[x][y] == ".":
        print(str(y) + " " + str(x))
        return
    elif Tile_map[x][y] == ">":
        move(Tiles_map, x, y+1, Loop_ch)
    elif Tile_map[x][y] == "<":
        move(Tiles_map, x, y-1, Loop_ch)
    elif Tile_map[x][y] == "v":
        move(Tiles_map, x+1, y, Loop_ch)
    elif Tile_map[x][y] == "^":
        move(Tiles_map, x-1, y, Loop_ch)

        
        
while True:
    Tile_map = []
    Loop_ch = []
    H, W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        Tiles = input()
        Tiles = list(str(Tiles))
        Tile_map.append(Tiles)
    ans = move(Tile_map,0,0,Loop_ch)