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: 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):
  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: for a in iter(input,'0 0'):
 m=[input()for _ in[0]*int(a.split()[0])]
 y=x=0;s={(0,0)}
 while 1:
  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
  if(x,y)in s:print('LOOP');break
  else:s|={(x,y)}

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

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

  mp = [input() for _ in range(h)]
  visited = [[False for _ in range(w)] for _ in range(h)]
  x, y = 0, 0

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

    tile = mp[y][x]

    if tile == ".":
      print(x, y)
      break
    
    visited[y][x] = True

    if tile == ">":
      x += 1
    elif tile == "<":
      x -= 1
    elif tile == "^":
      y -= 1
    else:
      y += 1

Python: X, Y = map(int, input().split())
while (X !=0 and Y != 0):
    Slist = []
    for i in range(X):
        S = list(map(str, input()))
        Slist.append(S)
    store = [(0,0)]
    x = 0
    y = 0
    while True:
        if (Slist[x][y] == '>'):
            y += 1
        elif (Slist[x][y] == '<'):
            y -= 1
        elif (Slist[x][y] == 'v'):
            x += 1
        elif (Slist[x][y] == '^'):
            x -= 1
            
        if (Slist[x][y] == '.'):
            loop = 0
            break     
        if ((x,y) in store):
            loop = 1
            break
        store.append((x,y))

    if (loop == 1):
        print('LOOP')
    elif (loop == 0) :  
        print(y,x)   
        
    X, Y = map(int, input().split())

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] != '.':
        if m[x][y] == 'x':
            break
        else:
            d = m[x][y]
            m[x][y] = 'x'
            x += DIR[d][0]
            y += DIR[d][1]

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

Python: def ans(m):
    h = 0
    w = 0
    pas = []

    while True:
#        print("h={0} v={1} mark={2}".format(h,w,m[h][w]))
        if   m[h][w] == '>':
            w += 1
        elif m[h][w] == '<':
            w -= 1
        elif m[h][w] == '^':
            h -= 1
        elif m[h][w] == 'v':
            h += 1
        elif m[h][w] == '.':
            return  "{0} {1}".format(w,h)

        if (h,w) in pas:
            return "LOOP"
        else:
            pas.append((h,w))

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

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

    res = ans(m)
    print(res)

Python: import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


North  = 0
East   = 1
South  = 2
West   = 3

DICT = {"^":North,">":East,"v":South,"<":West}

while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break

    base_map = [input() for _ in range(H)]
    check = [[False]*W for row in range(H)]

    row = 0
    col = 0

    while True:
        if base_map[row][col] == '.':
            print("%d %d"%(col,row))
            break
        else:
            if check[row][col] == True:
                print("LOOP")
                break

            check[row][col] = True
            tmp_dir = DICT[base_map[row][col]]

            if tmp_dir == North:
                row -= 1
            elif tmp_dir == East:
                col += 1
            elif tmp_dir == South:
                row += 1
            else: #tmp_dir == West
                col -= 1

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)