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:
    h, w = map(int, input().split())
    if h == 0:
        break

    t_list = []
    for i in range(h):
        t_list.append(input())

    p = [0,0]
    p_passed = []
    while True:
        t = t_list[p[1]][p[0]]
        if t == ">":
            p[0] += 1
        elif t == "<":
            p[0] -= 1
        elif t == "^":
            p[1] -= 1
        elif t == "v":
            p[1] += 1
        else:
            print(p[0], p[1])
            break
        if p in p_passed:
            print("LOOP")
            break
        p_passed.append(p[:])

Python: 
dir = {'>': (0, 1), '<': (0, -1), 'v': (1, 0), '^': (-1, 0)}

# solve function
def solve(h, w, tiles, visited):
     x, y = 0, 0

     while True:
         if tiles[y][x] == '.':
             print(x, y)
             break

         if not visited[y][x]:
             print("LOOP")
             break

         visited[y][x] = False

         next_y, next_x = dir[tiles[y][x]]

         x += next_x
         y += next_y

     return

# main function
if __name__ == '__main__':
    while True:
        # input param
        inputs = (input()).split()

        h = int(inputs[0])
        w = int(inputs[1])

        if h == 0 and w == 0:
            break

        visited = [[True for i in range(w)] for j in range(h)]
        tiles = ["" for i in range(h)]

        for i in range(h):
            tiles[i] = input()

        solve(h, w, tiles, visited)

Python: import sys
import math

def decide_move(x,y,tile,check):
	if tile == '<':
		x -= 1
		check[x][y] += 1
		return x,y,check
	elif tile == '>':
		x += 1
		check[x][y] += 1
		return x,y,check
	elif tile == '^':
		y -= 1
		check[x][y] += 1
		return x,y,check
	else:
		y += 1
		check[x][y] += 1
		return x,y,check


while True:
	h,w = map(int,input().split())
	if h == 0:
		break
	tile_map = []
	for i in range(h):
		tile_map.append(input())
	check =[[0 for i in range(w)]for j in range(h)]
	check[0][0] = 1
	x = 0
	y = 0
	status = 0

	while True:
		if tile_map[x][y] == '.':
			status = 1
			print(y,x)
			break
		x,y,check = decide_move(x,y,tile_map[x][y],check)
		if check[x][y] > 1:
			status = 1
			print('LOOP')
			break

Python: def moov(x,y):
    if (x,y) in Loc:
        return "LOOP"
    else:
        Loc.append((x,y))
        if Room[y][x] == ".":
            return str(x)+" "+str(y)
        elif Room[y][x] == ">":
            return moov(x + 1,y)
        elif Room[y][x] == "<":
            return moov(x - 1,y)
        elif Room[y][x] == "^":
            return moov(x,y - 1)
        elif Room[y][x] == "v":
            return moov(x,y + 1)
    

while True:
    Loc = []
    num = 0
    Room = []
    h,w = map(int,input().split())
    if h == w == 0:
        break
    for i in range(h):
        vec = input()
        Room.append(list(vec))
    print(moov(1,0))

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

while True:
    w, h = m(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: 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)]
    for i in range(w):
        m[i] = [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: import sys
#from me.io import dup_file_stdin

#@dup_file_stdin
def solve():
    while True:
        m = []
        h,w = map(int,sys.stdin.readline().split(" "))
        if h==0 and w==0:
            break
        for r in range(h):
            m.append(list(sys.stdin.readline()[:-1]))
        r=0
        c=0
        while m[r][c]!='*':
            if m[r][c]=='>':
                m[r][c]='*'
                c+=1
            elif m[r][c]=='<':
                m[r][c]='*'
                c-=1
            elif m[r][c]=='v':
                m[r][c]='*'
                r+=1
            elif m[r][c]=='^':
                m[r][c]='*'
                r-=1
            elif m[r][c]=='.':
                break
        if m[r][c]=='*':
            print("LOOP")
        else:
            print("{} {}".format(c,r))
solve()

Python: while True:
	H, W = list(map(int, input().split()))
	if H == 0 and W == 0:
		break
	else:
		a = list(input() for i in range(H))
		visitedlist = []
		h = 0
		w = 0
		while True:
			if (h, w) not in visitedlist:
				visitedlist.append([h, w])
				if a[h][w] == '>':
					w += 1
				if a[h][w] == '<':
					w -= 1
				if a[h][w] == '^':
					h -= 1
				if a[h][w] == 'v':
					h += 1
				if a[h][w] == '.':
					print(w, h)
					break
			else:
				print('LOOP')
				break

Python: while True:
    try:
        H,W = map(int,input().split())
        if H==W and H==0:
            break
    except:
        break
    
    x,y = 0,0
    room = []
    move_his = []
    flg = False
    for i in range(H):
        room.append([t for t in input()])
    
    while room[y][x] != ".":
        if room[y][x]==">":
            x+=1
        elif room[y][x]=="<":
            x-=1
        elif room[y][x]=="^":
            y-=1
        elif room[y][x]=="v":
            y+=1
        
        if [x,y] in move_his:
            flg = True
            break
        move_his.append([x,y])

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

Python: H, W = map(int, input().split())
tiles = [input() for _ in range(H)]
i = j = 0
info = {">": (0, 1), "<": (0, -1), "^": (-1, 0), "v": (1, 0), ".": (-1, -1)}
for cnt in range(H*W):
    a, b = info[tiles[i][j]]
    if a == b == -1:
        print(j, i)
        break
    i += a
    j += b
else:
    print("LOOP")

Python: while True:
  h,w = map(int,input().split())
  if (h,w) == (0,0):
    break
  l = []
  for i in range(h):
    l.append(input())
  x,y = 0,0
  l1 = []
  while True:
    if (x,y) in l1:
      print('LOOP')
      break
    l1.append((x,y))
    pos = l[y][x]
    if pos == '.':
      print(x,y)
      break
    elif pos == '<':
      x -= 1
    elif pos == '>':
      x += 1
    elif pos == '^':
      y -= 1
    elif pos == 'v':
      y += 1

Python: posX,posY=0,0
H,W=map(int,input())
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