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: #!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def main(readline=stdin.readline):
    while 1:
        h, w = (int(s) for s in readline().split())
        if h == 0:
            exit()

        room = [readline().rstrip() for col in range(h)]
        x = y = 0
        current = x * 1000 + y
        passed = set()

        while 1:
            passed.add(current)
            tile = room[y][x]

            if tile == '>':
                x += 1
            elif tile == '<':
                x -= 1
            elif tile == 'v':
                y += 1
            elif tile == '^':
                y -= 1
            else:
                print(x, y)
                break

            current = x * 1000 + y
            if current in passed:
                print('LOOP')
                break


if __name__ == '__main__':
    main()

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0104&lang=jp
"""
import sys


class MagicalTiles():
    def __init__(self, data):
        self.map = data[:]
        self.pos = (0, 0)
        self.path = [(0, 0)]
        self.mark = self.map[0][0]
        self.loop = False

    def move(self):
        x, y = self.pos[0], self.pos[1]
        self.mark = self.map[y][x]
        if self.mark == '>':
            x += 1
        elif self.mark == '<':
            x -= 1
        elif self.mark == '^':
            y -= 1
        elif self.mark == 'v':
            y += 1
        if self.mark != '.' and (x, y) in self.path:
            self.loop = True
        else:
            self.path.append((x, y))
        self.pos = (x, y)


def main(args):
    # data = []
    # data.append('>>>v..>>>v')
    # data.append('...v..^..v')
    # data.append('>>>>>>^..v')
    # data.append('.........v')
    # data.append('.v<<<<...v')
    # data.append('.v.v.^...v')
    # data.append('.v.v.^<<<<')
    # data.append('.v.v.....v')
    # data.append('.v...^...v')
    # data.append('.>>>>^....')
    #
    # data = []
    # data.append('>>>>>>>>>v')
    # data.append('.........v')
    # data.append('.........v')
    # data.append('>>>>v....v')
    # data.append('^...v....v')
    # data.append('^<<<<<<<<<')
    while True:
        h, w = [int(x) for x in input().split(' ')]
        if h == 0 and w == 0:
            break
        data = [input() for _ in range(h)]

        m = MagicalTiles(data)
        while m.mark != '.':
            m.move()
            if m.loop:
                break
        if m.loop:
            print('LOOP')
        else:
            print(m.pos[0], m.pos[1])


if __name__ == '__main__':
    main(sys.argv[1:])

Python: import sys
import math

def decide_move(x,y,tile,check):
	if tile == '<':
		y -= 1
		check[x][y] += 1
		return x,y,check
	elif tile == '>':
		y += 1
		check[x][y] += 1
		return x,y,check
	elif tile == '^':
		x -= 1
		check[x][y] += 1
		return x,y,check
	else:
		x += 1
		check[x][y] += 1
		return x,y,check


while True:
	h,w = map(int,input().split())
	if h == 0:
		break
	tile_map = []
	for i in range(h):
		tile_map.append(input())
	check =[[0 for i in range(w)]for j in range(h)]
	check[0][0] = 1
	x = 0
	y = 0
	status = 0

	while True:
		if tile_map[x][y] == '.':
			status = 1
			print(y,x)
			break
		x,y,check = decide_move(x,y,tile_map[x][y],check)
		if check[x][y] > 1:
			status = 1
			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 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 search(table, visited, x, y):
    if visited[x][y]:
        print("LOOP")
        return

    visited[x][y] = True

    if table[x][y] == ">":
        search(table, visited, x, y+1)
    elif table[x][y] == "v":
        search(table, visited, x+1, y)
    elif table[x][y] == "^":
        search(table, visited, x-1, y)
    elif table[x][y] == "<":
        search(table, visited, x, y-1)
    elif table[x][y] == ".":
        print(y, x)
        return


while True:
    X, Y = [int(i) for i in input().split()]
    if X == 0 and Y == 0:
        break

    table = [[0 for i in range(Y)] for j in range(X)]
    visited = [[False for i in range(Y)] for j in range(X)]

    for i in range(X):
        L = input()
        for j in range(Y):
            table[i][j] = L[j]

    search(table, visited, 0, 0)

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: 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 c=='.':print(x,y);break
  else:s|={(x,y)}
 else:print('LOOP')

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")