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

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))




int main(){
	vector <string>res;
	while(1){
		int H,W;
		cin>>H>>W;
		if(H==0&&W==0)break;
		char c[102][102];
		REP(i,H)REP(j,W)cin>>c[i][j];
		int tx=0,ty=0;
		int x=0,y=0;
		vector<PII>pi;
		set<PII>sp;
		int cnt=0;
		bool ch=true;
		while(c[y][x]!='.'){
			sp.insert(MP(x,y));
			if(c[y][x]=='>'){
				tx=1;ty=0;
			}else if(c[y][x]=='v'){
				tx=0;ty=1;
			}else if(c[y][x]=='<'){
				tx=-1;ty=0;
			}else if(c[y][x]=='^'){
				tx=0;ty=-1;
			}
			x+=tx;y+=ty;
			if(sp.find(MP(x,y))!=sp.end()){
				ch=false;
				break;
			}
		}
		if(ch){
			res.PB(toString(x)+' '+toString(y));
		}else{
			res.PB("LOOP");
		}
	}
	REP(i,SZ(res))cout<<res[i]<<endl;
}

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

struct Point{
	int x; int y; Point(){ x = 0; y = 0; }
};

int main(){
	const int h_max = 101;
	const int w_max = 101;
	int h, w;
	int a[h_max][w_max];

	while (cin >> h >> w , h*w != 0){

	for (int i = 0; i < h_max; ++i){
		for (int j = 0; j < w_max; ++j){
			a[i][j] = 0;
		}
	}

	
		string s;
		for (int i = 0; i < h; ++i){
			cin >> s;
			for (int j = 0; j < s.length(); ++j){
				switch ((int)s[j]){
				case (int)'>':
					a[j][i] = 1;
					break;
				case (int)'<':
					a[j][i] = 2;
					break;
				case (int)'^':
					a[j][i] = 3;
					break;
				case (int)'v':
					a[j][i] = 4;
					break;
				case (int)'.':
					a[j][i] = 5;
					break;
				}
			}
		}


		Point p;
		int count = 0; bool  is_loop = false;
		while (a[p.x][p.y] != 5 && is_loop == false){
			switch (a[p.x][p.y])
			{
			case 1:
				++p.x;
				break;
			case 2:
				--p.x;
				break;
			case 3:
				--p.y;
				break;
			case 4:
				++p.y;
				break;
			}

			++count;
			if (count > 101 * 101){
				is_loop = true;
			}
		}
		if (!is_loop){
			cout << p.x << " " << p.y << endl;
		}
		else{
			cout << "LOOP" << endl;
		}
	}
	
	/*
	for (int i = 0; i < h_max; ++i){
		for (int j = 0; j < w_max; ++j){
			cout << a[i][j];
		}
		cout << endl;
	}
	*/
	


	return 0;
}

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

char map[101][101];
int f[101][101];

int main() {
	int w, h, x, y, e;
	while(1) {
		cin >> h >> w;
		if(!w&&!h) break;
		for(int i=0; i<h; ++i) {
			cin >> map[i];
			for(int j=0; j<w; ++j) f[i][j] = 0;
		}
		x = y = 0; e = 0;
		while(1) {
			f[y][x] = 1;
			switch(map[y][x]) {
			case '>': x+=1; break;
			case '<': x-=1; break;
			case 'v': y+=1; break;
			case '^': y-=1; break;
			case '.': e = 1; break;
			}
			if(e || f[y][x]) break;
		}
		if(e) cout << x << " " << y << endl;
		else cout << "LOOP" << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

VS mp;
int n, m, x, y;
char mp_input[ 200 ];
bool gone[ 200 ][ 200 ];

int main() {
	while ( ~scanf( "%d %d", &n, &m ) && n && m ) {
		mp.resize( n );
		for ( int i = 0; i < n; i++ ) {
			scanf( "%s", mp_input );
			mp[ i ] = ( string ) mp_input;
		}
		memset( gone, 0, sizeof( gone ) );
		x = y = 0;
		while ( mp[ y ][ x ] != '.' ){
			if ( gone[ y ][ x ] ) {
				break;
			}
			gone[ y ][ x ] = true;
			if ( mp[ y ][ x ] == '>' ) {
				x++;
			}
			else if ( mp[ y ][ x ] == '<' ) {
				x--;
			}
			else if ( mp[ y ][ x ] == '^' ) {
				y--;
			}
			else if ( mp[ y ][ x ] == 'v' ) {
				y++;
			}
		}
		if ( gone[ y ][ x ] ) {
			printf( "LOOP\n" );
		}
		else {
			printf( "%d %d\n", x, y );
		}
	}
	return 0;
}