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

Python: while True:
  H,W = list(map(int,input().split()))
  if (H,W) == (0,0):
    break
  x,y = (0,0)
  log = [(x,y)]
  # floor[y][x] == floor[H][W]
  floor = [list(input()) for i in range(H)]

  while True:
    if floor[y][x] == ".":
      print(x,y)
      break
    elif floor[y][x] == ">":
      log.append((x,y))
      x += 1
    elif floor[y][x] == "<":
      log.append((x,y))
      x -= 1
    elif floor[y][x] == "^":
      log.append((x,y))
      y -= 1
    elif floor[y][x] == "v":
      log.append((x,y))
      y += 1
    #
    if (x,y) in log:
      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 = []
    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: # -*- 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 > H * W:
            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: 
while(True):
    ny,nx = map(int, input().split())
    if nx == 0 and ny == 0:
        break
    dic = {">":[1,0],"<":[-1,0],"^":[0,-1],"v":[0,1],".":[0,0]}
    poshist = []
    ma = [input() for i in range(ny)]
    px,py = 0,0
    poshist.append([px,py])
    while(True):
        px += dic[ma[py][px]][0]
        py += dic[ma[py][px]][1]
        if [px,py] in poshist:
            poshist.append([px,py])
            break
        else:
            poshist.append([px,py])
    if poshist[-1] == poshist[-2]:
        print(poshist[-1][0],poshist[-1][1])
    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:
  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
  if(x,y)in s:print('LOOP');break
  else:s|={(x,y)}

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 1:
    h,w=map(int,input().split())
    if w==0:break
    a=[input() for _ in[0]*h]
    b=[(0,0)];i=j=0
    while a[i][j]!='.':
        if a[i][j]=='>':j+=1
        elif a[i][j]=='<':j-=1
        elif a[i][j]=='v':i+=1
        elif a[i][j]=='^':i-=1
        if (i,j) in b:print('LOOP');break
        b+=[(i,j)]
    else:print(j,i)

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

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: def judgement(tmp,matrix):
    judge=[]
    x,y=0,0
    while True:
        if [x,y] in judge:
            print("LOOP")
            break
        judge.append([x,y])
        #print(judge)
        if tmp[x][y]=='>':
            y+=1
        elif tmp[x][y]=='<':
            y-=1
        elif tmp[x][y]=='^':
            x-=1
        elif tmp[x][y]=='v':
            x+=1
        else:
            print(y,x)
            break

while True:
    H,W=map(int, input().split())
    if H==W==0:
        break
    matrix=[[0 for i in range(W)] for i in range(H)]
    tmp=[]
    for i in range(H):
        hhh=list(map(str,input()))
        tmp.append(hhh)
    #print(tmp)
    judgement(tmp,matrix)

Python: def run_magic_tiles(magic_tiles, past_matrix):
    def move_up(x, y):
        return x - 1, y

    def move_down(x, y):
        return x + 1, y

    def move_left(x, y):
        return x, y - 1

    def move_right(x, y):
        return x, y + 1

    def goal():
        return -1, -1

    i, j = 0, 0
    while True:
        res = {
            '^': move_up(i, j),
            'v': move_down(i, j),
            '<': move_left(i, j),
            '>': move_right(i, j),
            '.': goal()
        }.get(magic_tiles[i][j])
        if res[0] == -1 and res[1] == -1:
            return j, i
        else:
            i, j = res
            if past_matrix[i][j]:
                return 'LOOP'
            past_matrix[i][j] = 1


def main():
    while True:
        c, r = map(int, input().split(' '))
        if c == 0 and r == 0:
            break

        past_matrix = [[0 for _ in range(r)] for _ in range(c)]
        tiles = []
        for _ in range(c):
            tiles.append(list(input()))

        res = run_magic_tiles(tiles, past_matrix)
        print('LOOP' if res == 'LOOP' else '%d %d' % (res[0], res[1]))


if __name__ == '__main__':
    main()

Python: import sys
while True:
    H,W=[int(i) for i in input().split(" ")]
    if H==0 and W==0:
        break
    Tiles=[]
    for i in range(H):
        Tiles.append(input())

    step=0

    x=0
    y=0
    while True:

        if Tiles[y][x]==">":
            x+=1
        elif Tiles[y][x]=="<":
            x-=1
        elif Tiles[y][x]=="^":
            y-=1
        elif Tiles[y][x]=="v":
            y+=1
        step+=1

        if Tiles[y][x]==".":
            print(x,y)
            break
        if step>H*W+5:
            print("LOOP")
            break