Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	// var w, h int
	for scanner.Scan() {
		// fmt.Scanf("%d %d", &w, &h)

		input := strings.Split(scanner.Text(), " ")
		w, _ := strconv.Atoi(input[0])
		h, _ := strconv.Atoi(input[1])

		if w == 0 && h == 0 {
			return
		}

		isArrive := make([][]bool, w)
		tiles := make([][]string, w)

		for i := 0; i < w; i++ {
			rowArrive := make([]bool, h)
			rowTiles := make([]string, h)
			scanner.Scan()
			row := scanner.Text()
			for j := 0; j < h; j++ {
				rowTiles[j] = string(row[j])
			}
			tiles[i] = rowTiles
			isArrive[i] = rowArrive
		}

		var i, j int
		isEnd := false
		for {
			if isArrive[i][j] == true {
				fmt.Println("LOOP")
				break
			}
			isArrive[i][j] = true

			switch tiles[i][j] {
			case ">":
				j++
			case "^":
				i--
			case "v":
				i++
			case "<":
				j--
			case ".":
				isEnd = true
			}

			if isEnd == true {
				fmt.Println(j, i)
				break
			}
		}
	}
}

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
        elif tileinfo[posX][posY]=='^':
            posY-=1
        elif tileinfo[posX][posY]=='.':
            print('{} {}'.format(posX,posY))
            break
        if tile[posX][posY]==True:
            print('LOOP')
            break
        else:
            tile[posX][posY]=True

Python: # AOJ 0104 Magical Tiles
# Python3 2018.6.17 bal4u

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

	a = [0]*h
	for r in range(h): a[r] = list(input())
	r = c = 0
	while True:
		k = a[r][c]
		a[r][c] = '#'
		if k == '#':
			print('LOOP')
			break
		elif k == '>': c += 1
		elif k == '<': c -= 1
		elif k == '^': r -= 1
		elif k == 'v': r += 1
		elif k == '.':
			print(c, r)
			break

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

Python: while 1:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break

    mat = []
    for _ in range(h):
        mat.append(list(input()))

    x = 0
    y = 0
    cnt = 0
    flag = False
    while mat[x][y] != '.':
        cnt += 1
        if mat[x][y] == '>':
            y += 1
        elif mat[x][y] == '<':
            y -= 1
        elif mat[x][y] == '^':
            x -= 1
        elif mat[x][y] == 'v':
            x += 1

        if cnt == 10**4:
            flag = True
            break

    if flag:
        print("LOOP")
    else:
        print(y, x)

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()