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<iostream>
#include<string>

using namespace std;

string a[102];
int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
int X, Y, gx, gy;

int dfs(int y, int x){
  int i;
  if(y < 0 || Y <= y || x < 0 || X <= x || a[y][x] == '.') { gx = x; gy = y; return 0;}
  if(a[y][x] == '#') return 1;
  if(a[y][x] == '^')      i = 0;
  else if(a[y][x] == '>') i = 1;
  else if(a[y][x] == 'v') i = 2;
  else                    i = 3;
  a[y][x] = '#';
  dfs(y + dy[i], x + dx[i]);
}

int main(){
  while(cin >> Y >> X, X != 0 || Y != 0) {
    for(int i = 0; i < Y ; i++)
      cin >> a[i];
    if(dfs(0, 0) == 1)cout << "LOOP" << endl;
    else  cout << gx << ' ' << gy << endl;
  }
}

C++: #include<cstdio>
#include<iostream>
  
using namespace std;
  
int main(void){

	int W,H;
	int x,y;
	bool f;
	char stage[101][101];

	while(1){
		cin>>H>>W;
		if(H==0&&W==0) break;
		getchar();
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				stage[i][j]=getchar();
			}
			getchar();
		}
		x=0,y=0;
		f=true;
		while(f){
			switch(stage[y][x]){
				case '>':
					stage[y][x]='-';
					x+=1;
					break;
				case '<':
					stage[y][x]='-';
					x-=1;
					break;
				case '^':
					stage[y][x]='-';
					y-=1;
					break;
				case 'v':
					stage[y][x]='-';
					y+=1;
					break;
				case '.':
					cout<<x<<" "<<y<<endl;
					f=false;
					break;
				case '-':
					cout<<"LOOP"<<endl;
					f=false;
					break;
				default:
					cout<<"error"<<endl;
					return -1;
			}
		}
	}

	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 "ROOP" E
			return;
		}
	}
	CO posn[1] << " " << posn[0] E


}

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

	return 0;
}

C++: 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
template<class _T>
inline void _prfe(const char *_n, _T _c, bool _p = false){
    ITER(_c) _it=_c.begin();
    if(_p){ cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{ cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

int main(){
    int h,w;
    while(cin >> h >> w){
        if(h == 0 && w == 0) break;
        vector<string> vs;
        string s;
        REP(y,h){
            cin >> s;
            vs.pb(s);
        }
        int x = 0, y = 0;
        bool flag = true;
        while(flag){
            char c = vs[y][x];
            switch(c){
            case '.': case 'x':
                flag = false; break;
            case '<': case '>':
            case '^': case 'v':
                vs[y][x] = 'x';
                switch(c){
                case '<': x--; break;
                case '>': x++; break;
                case '^': y--; break;
                case 'v': y++; break;
                }
            }

        }
        if(vs[y][x] == 'x'){
            cout << "LOOP" << endl;
        } else {
            cout << x << " " << y << endl;
        }
    }
    return 0;
}

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

int main(){
	string str[100];
	int v[100][100];
	int h, w;
	while(cin >> h >> w, h){
		fill((int*)v, (int*)(v+100), false);
		for(int i = 0;i < h;i++)cin >> str[i];
		int x = 0, y = 0;
		while(1){
			if(str[y][x] == '.'){cout << x << " " << y << endl;break;}
			if(v[y][x]){cout << "LOOP" << endl;break;}
			v[y][x] = true;
			if(str[y][x] == '>')x++;
			if(str[y][x] == '<')x--;
			if(str[y][x] == '^')y--;
			if(str[y][x] == 'v')y++;
		}
	}
}