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: STATE = {
    "NOTHING": ".",
    "LOOP": "E"
}

DIRECT = {
    ">": [0, 1],
    "<": [0, -1],
    "^": [-1, 0],
    "v": [1, 0]
}

output = []

while True:

    width, height = [int(item) for item in input().split(" ")]

    if width == 0 and height == 0:
        break

    tiles = []
    for lp in range(width):
        splits = [item for item in input()]
        tiles.append(splits)

    row, col = 0, 0
    while True:

        if tiles[row][col] == STATE["NOTHING"]:
            output.append(str(col) + " " + str(row))
            break
        elif tiles[row][col] == STATE["LOOP"]:
            output.append("LOOP")
            break

        for key in DIRECT:
            if tiles[row][col] == key:
                tiles[row][col] = STATE["LOOP"]
                row += DIRECT[key][0]
                col += DIRECT[key][1]
                break


print("\n".join(output))

Python: while True:
    h,w = [int(x) for x in input().split()]
    if h == 0 and w ==0:
        break
    
    T = [  [0] * w  for x in range(h) ]
    M = []
    for _ in range(h):
        M.append(list(input()))
        
    i=0 
    j=0
    loop = 0
    while True:
        if T[i][j] > 0:
            loop += 1
            break
        else:
            T[i][j] += 1
        
        if M[i][j] ==".":
            break
        elif M[i][j] == ">":
            j += 1
        elif M[i][j] == "<":
            j -= 1
        elif M[i][j] == "^":
            i -= 1
        else:
            i += 1
    
    if loop > 0:
        print("LOOP")
    else:
        print(j,i)

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

while True:
    H, W = map(int, input().split())
    if H == 0:
        break
    tiles = [input() for _ in range(H)]
    i = j = 0
    for _ 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: 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