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
			}
		}
	}
}

C++: #include<cstdio>
#include<cstring>


int main()
{
	int w,k,hyou[100][100],i,j,checki[100],check[100],l=0;
	memset(check,0,100*sizeof(int));
	char a;
	while(1)
	{
		scanf("%d%d",&w,&k);
		if(w==0)
			break;
		scanf("%c",&a);
		for(i=0;i<w;i++)
		{
			for(j=0;j<=k;j++)
			{
				scanf("%c",&a);
				if(a=='>')
					hyou[i][j]=1;
				else	if(a=='<')
					hyou[i][j]=2;
				else if(a=='v')
					hyou[i][j]=3;
				else if(a=='^')
					hyou[i][j]=4;
				else if(a=='.')
					hyou[i][j]=0;
				else 
					hyou[i][j]=6;
			}
			
			
		}
		i=0;
		j=0;
		while(hyou[i][j]!=5&&hyou[i][j]!=0)
		{
			switch(hyou[i][j])
			{
			case 1:
				hyou[i][j]=5;
				j++;
				break;
			case 2:
				hyou[i][j]=5;
				j--;
				break;
			case 3:
				hyou[i][j]=5;
				i++;
				break;
			case 4:
				hyou[i][j]=5;
				i--;
				break;
			case 0:
				check[l]=i;
				checki[l]=j;
				break;
			case 5:
				check[l]=0;
				break;
			}
		}
		if(hyou[i][j]==0)
		{	check[l]=i;
			checki[l]=j;}
		if(hyou[i][j]==5)
			check[l]=-1;
		l++;
	}
	for(i=0;i<l;i++)
	{
		if(check[i]==-1)
			printf("LOOP\n");
		else
			printf("%d %d\n",checki[i],check[i]);
	}
	return 0;
}

C++: #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main()
{
	int N, M;
	vector<string>data;
	while (cin >> N >> M, N || M)
	{
		data.clear();
		data.resize(N);
		for (size_t i = 0; i < N; i++)
		{
			cin >> data[i];
		}
		int nowx = 0, nowy = 0;
		while (data[nowx][nowy] != '.' && data[nowx][nowy] != 1)
		{
			switch (data[nowx][nowy])
			{
				case '>':{
						data[nowx][nowy] = 0;
						nowy++;
						break;
					}
				case '<':{
						data[nowx][nowy] = 0;
						nowy--;
						break;
					}
				case '^':{
						data[nowx][nowy] = 0;
						nowx--;
						break;
					}
				case 'v':{
						data[nowx][nowy] = 0;
						nowx++;
						break;
					}
				case 0:{
						data[nowx][nowy] = 1;
						break;
					}
				default:break;
			}
		}
		if (data[nowx][nowy] == 1) cout << "LOOP" << endl;
		else cout << nowy << " " << nowx << endl;
	}
	return 0;
}

C++: /*
	0104:Magical Tiles
*/
#include	<iostream>

using namespace std;

//GV
char map[101][101];

//FN
void refmaps(void);
void start(void);

int main(void) {
	while(1) {
		int W, H;
		
		refmaps();
		
		cin >> H >> W;
		if(H == 0 && W == 0) { break; }
		
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				char c;
				cin >> c;
				map[i][j] = c;
			}
		}
		
		start();
	}
	return 0;
}

void refmaps(void) {
	for(int i = 0; i < 101; i++) {
		for(int j = 0; j < 101; j++) {
			map[i][j] = '.';
		}
	}
}

void start(void) {
	int h = 0, w = 0;
	const int vx[4] = {1, 0, -1, 0}, vy[4] = {0, 1, 0, -1};
	const char vc[4] = {'>', 'v', '<', '^'};
	
	while(1) {
		if(map[h][w] == '.') { cout << w << ' ' << h << endl; return; }
		else if(map[h][w] == 'L') { cout << "LOOP" << endl; return; }
		else {
			for(int i = 0; i < 4; i++) {
				if(map[h][w] == vc[i]) {
					map[h][w] = 'L';
					h += vy[i];		w += vx[i];
				}
			}
		}
	}
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int h, w;
char board[110][110];
string dir = "v^><";
signed main() {
    while(cin >> h >> w, h || w) {
        rep(i,0,h) rep(j,0,w) cin >> board[i][j];
        bool used[110][110] = {}, loop = false;
        int x = 0, y = 0;
        while(1) {
            if(board[x][y] == '.') break;
            if(used[x][y]) {loop = true; break;}
            used[x][y] = true;
            int t = dir.find(board[x][y]);
            x += dx[t], y += dy[t];
        }
        if(loop) cout << "LOOP" << endl;
        else printf("%lld %lld\n", y, x);
    }
    return 0;
}