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: H,W=1,1
while True:
    posX,posY=0,0
    H,W=map(int,input().split())
    if (H==W==0)==True:
        break
    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 tile[posY][posX]==True:
            print('LOOP')
            break
        else:
            tile[posY][posX]=True
        if tileinfo[posY][posX]=='>':
            posX+=1
        elif tileinfo[posY][posX]=='<':
            posX-=1
        elif tileinfo[posY][posX]=='v':
            posY+=1
        elif tileinfo[posY][posX]=='^':
            posY-=1
        elif tileinfo[posY][posX]=='.':
            print('{} {}'.format(posX,posY))
            break

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):
  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
 else:print('LOOP')

Python: import sys
from pprint import pprint
def main():
    for line in sys.stdin:
        H,W = map(int, line.split())

        if H == 0 and W == 0:
            break

        else:
            t = []
            for _ in range(H):
                t.append(list(input()))

            x,y = 0,0
            cnt = 0
            while True:
                cnt += 1
                if t[x][y] == ">":
                    y += 1
                elif t[x][y] == "v":
                    x += 1
                elif t[x][y] == "<":
                    y -= 1
                elif t[x][y] == "^":
                    x -= 1
                elif t[x][y] == ".":
                    f = 0
                    break

                if cnt > H * W:
                    f = 1
                    break
                else:
                    pass

            if f == 0:
                print(y, x)
            elif f == 1:
                print("LOOP")


if __name__ == "__main__":
    main()

Python: if __name__ == '__main__':

	while True:
		x,y = map(int,input().split())

		if x == 0 and y == 0:
			break

		A = []
		for _ in range(x):
			line = list(input())
			A.append(line)

		ans = []
		W = 0
		H = 0
		s = A[H][W]
		while True:
			if s == ">":
				W += 1
			elif s == "<":
				W -= 1
			elif s == "^":
				H -= 1
			elif s == "v":
				H += 1
			else:
				print(W,H)
				break

			s = A[H][W]
			if [H,W] in ans:
				print("LOOP")
				break
			else:
				ans.append([H,W])

Python: while True :
    H, W = map(int, input().split())
    if H == 0 and W == 0 :
        break
    
    roop = "OFF"
    Tile = [list(input()) for j in range(H)]
    cursol_H = 0
    cursol_W = 0
    roop = "OFF"
    while True :
        if Tile[cursol_H][cursol_W] == ">" :
            Tile[cursol_H][cursol_W] = "/"
            cursol_W += 1
        elif Tile[cursol_H][cursol_W] == "v" :
            Tile[cursol_H][cursol_W] = "/"
            cursol_H += 1
        elif Tile[cursol_H][cursol_W] == "<" :
            Tile[cursol_H][cursol_W] = "/"
            cursol_W -= 1
        elif Tile[cursol_H][cursol_W] == "^" :
            Tile[cursol_H][cursol_W] = "/"
            cursol_H -= 1
        elif Tile[cursol_H][cursol_W] == "/" :
            roop = "ON"
            break
        else :
            break
    
    if roop == "ON" :
        print("LOOP")
    else :
        print(cursol_W, cursol_H)

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 > 150:
            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: dp=[[""] * 100 for i in range(100)]

while(1):
    try:
        h,w = (int(x) for x in input().split())
        if w == 0:
            break
        s = ""
        x = y = 0
        ans = "LOOP"
        for i in range(0,h):
            s += input()
        for i in range(0,h):
            for j in range(0,w):
                dp[i][j] = s[i * w + j]

        while(1):
            c = dp[y][x]
            dp[y][x] = 'd'
            if(c == '>'):
                x += 1
            if(c == 'v'):
                y += 1
            if(c == '^'):
                y -= 1
            if(c == '<'):
                x -= 1
            if(c == 'd'):
                break;
            if(c == '.'):
                ans = str(x)+ ' ' + str(y)
                break
        print(ans)
    except EOFError:
        break

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

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

Python: while True:
    h,w=map(int,input().split())
    if (h,w)==(0,0):
        break
    roop=[[False for i in range(w)]for j in range(h)]
    s=[input() for _ in range(h)]
    x,y=0,0
    jud=True
    while s[y][x]!='.':
        if roop[y][x]:
            print("LOOP")
            jud=False
            break
        roop[y][x]=True
        if s[y][x]=='>':
            x+=1
        elif s[y][x]=='<':
            x-=1
        elif s[y][x]=='v':
            y+=1
        else:
            y-=1
    if jud:
        print(x,y)