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: while True:
    try:
        H,W = map(int,input().split())
        if H==W and H==0:
            break
    except:
        break
    
    x,y = 0,0
    room = []
    move_his = []
    flg = False
    for i in range(H):
        room.append([t for t in input()])
    
    while room[y][x] != ".":
        if room[y][x]==">":
            x+=1
        elif room[y][x]=="<":
            x-=1
        elif room[y][x]=="^":
            y-=1
        elif room[y][x]=="v":
            y+=1
        
        if [x,y] in move_his:
            flg = True
            break
        move_his.append([x,y])

    if flg:
        print("LOOP")
    else:
        print(x,y)

Python: H, W = map(int, input().split())
tiles = [input() for _ in range(H)]
i = j = 0
info = {">": (0, 1), "<": (0, -1), "^": (-1, 0), "v": (1, 0), ".": (-1, -1)}
for cnt 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: while True:
  h,w = map(int,input().split())
  if (h,w) == (0,0):
    break
  l = []
  for i in range(h):
    l.append(input())
  x,y = 0,0
  l1 = []
  while True:
    if (x,y) in l1:
      print('LOOP')
      break
    l1.append((x,y))
    pos = l[y][x]
    if pos == '.':
      print(x,y)
      break
    elif pos == '<':
      x -= 1
    elif pos == '>':
      x += 1
    elif pos == '^':
      y -= 1
    elif pos == 'v':
      y += 1

Python: posX,posY=0,0
H,W=map(int,input())
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: #!/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')