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

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)