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: 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):
        m.append([c for c in raw_input().strip()])

    x = 0
    y = 0
    while m[x][y] != '.':
        i = m[x][y]
        if i == 'x':
            break
        m[x][y] = 'x'
        x += DIR[i][0]
        y += DIR[i][1]

    if m[x][y] == '.':
        print("{} {}".format(y, x))
    else:
        print("LOOP")

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

Python: def move(Tiles_map, x, y, Loop_ch):
    if [x,y] in Loop_ch:
        print("LOOP")
        return
    else:
        Loop_ch.append([x,y])

    if Tile_map[x][y] == ".":
        print(str(y) + " " + str(x))
        return
    elif Tile_map[x][y] == ">":
        move(Tiles_map, x, y+1, Loop_ch)
    elif Tile_map[x][y] == "<":
        move(Tiles_map, x, y-1, Loop_ch)
    elif Tile_map[x][y] == "v":
        move(Tiles_map, x+1, y, Loop_ch)
    elif Tile_map[x][y] == "^":
        move(Tiles_map, x-1, y, Loop_ch)

        
        
while True:
    Tile_map = []
    Loop_ch = []
    H, W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        Tiles = input()
        Tiles = list(str(Tiles))
        Tile_map.append(Tiles)
    ans = move(Tile_map,0,0,Loop_ch)

Python: import sys
import math

def decide_move(x,y,tile,check):
	if tile == '<':
		x -= 1
		check[x][y] += 1
		return x,y,check
	elif tile == '>':
		x += 1
		check[x][y] += 1
		return x,y,check
	elif tile == '^':
		y -= 1
		check[x][y] += 1
		return x,y,check
	else:
		y += 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[i] = 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: while True:
    h, w = [int(x) for x in input().split()]
    if h == w == 0:
        break
    bool_ = [[0 for x in range(w)] for y in range(h)]
    tile = []
    for i in range(h):
        tile.append(list(input()))
    x, y = 0, 0
    while True:
        if bool_[y][x]:
            print('LOOP')
            break
        else:
            bool_[y][x] = 1
            if tile[y][x] == '>':
                x += 1
            elif tile[y][x] == '<':
                x -= 1
            elif tile[y][x] == '^':
                y -= 1
            elif tile[y][x] == 'v':
                y += 1
            elif tile[y][x] == '.':
                print(x, y)
                break

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

C++: #include <iostream>
#include <vector>
using namespace std;

int main(void) {
  int H, W;
  while (cin >> H >> W, H || W) {
    vector<vector<char> > tiles(H, vector<char>(W));

    for (auto i = 0; i < H; i++) {
      for (auto j = 0; j < W; j++) {
        cin >> tiles[i][j];
      }
    }

    bool flag = true;
    int nowX = 0, nowY = 0;
    int max_num = H * W + 1;
    while (max_num-- && flag) {
      switch(tiles[nowY][nowX]) {
      case '>':
        nowX++;
        break;
      case '<':
        nowX--;
        break;
      case '^':
        nowY--;
        break;
      case 'v':
        nowY++;
        break;
      default:
        flag = false;
        break;
      }
    }

    if (max_num > 0) {
      cout << nowX << " " << nowY << endl;
    } else {
      cout << "LOOP" << endl;
    }
  }
  return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

int A = 0, B = 0, C = 0, K = 0, S = 0, T = 0, W = 0, N = 0,H = 0;
int n = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string c;
string sA, strB;
vector<vector<char>> map;
vector<int> population;


void input() {
	CI W >> H;
	
	map.resize(W);
	REP(i, W) {
		map[i].resize(H);
	}
	REP(i, W) {
		REP(j, H) {
			CI map[i][j];
		}
	}
}

void proce() {
	int posn[2] = { 0,0 };
	vector<vector<bool>> check(W, vector<bool>(H, false));
	

	while (map[posn[0]][posn[1]] != '.') {
		check[posn[0]][posn[1]] = true;
		if (map[posn[0]][posn[1]] == '>') {
			posn[1]++;
		}
		else {
			if (map[posn[0]][posn[1]] == 'v') {
				posn[0]++;
			}
			else {
				if (map[posn[0]][posn[1]] == '<') {
					posn[1]--;
				}
				else {
					if (map[posn[0]][posn[1]] == '^') {
						posn[0]--;
					}
				}
			}
		}
		if (check[posn[0]][posn[1]] == true) {
			CO "LOOP" E
			return;
		}
	}
	CO posn[1] << " " << posn[0] E


}

int main(void) {
	
	while (true) {
		input();
		if (W == 0 && H == 0) {
			break;
		}
		proce();
	}

	return 0;
}