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 <stdio.h>

int main(void){	
	int x, y;
	int w, h;
	int loop;
	char tile[101][101];


	while(1){
		x = 0;
		y = 0;
		loop = 0;

		for(int i=0; i<101; i++){
			for(int j=0; j<101; j++){
				tile[i][j] = 0;
			}
		}

		scanf("%d %d", &h, &w);
		if(w == 0 && h == 0) break;
		for(int i=0; i<h; i++){
			scanf("%s", tile[i]);
		}

		while(1){
			char c = tile[y][x];
			tile[y][x] = 'x';

			if(c == '>') x++;
			else if(c == '<') x--;
			else if(c == '^') y--;
			else if(c == 'v') y++;
			else if(c == '.') break;
			else{
				loop = 1;
				break;
			}
		}
		if(loop == 0)printf("%d %d\n", x, y);
		else printf("LOOP\n");
	}
	return 0;
}

C++: #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>

using namespace std;

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#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())

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

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

char field[100][100];

void move(int h, int w) {
  char c = field[h][w];
  if(c == '.') cout << w << ' ' << h << endl;
  else if(c == '#') cout << "LOOP" << endl;
  else {
    field[h][w] = '#';
    if(c == '<') move(h, w-1);
    else if(c == '>') move(h, w+1);
    else if(c == 'v') move(h+1, w);
    else move(h-1, w);
  }
}

int main() {
  int h, w;

  while(1) {
    cin >> h >> w;
    if(h == 0 && w == 0) break;
  
    REP(i, h) {
      REP(j, w) {
	char c;
	cin >> c;
	field[i][j] = c;
      } 
    }
    move(0, 0);
  }
}

C++: #include <iostream>
#include <cstdio>
#include <string>

using namespace std;

string mp[100];
string dir = "^>v<";
const int dy[4] = {-1,0,1,0}, dx[4] = {0,1,0,-1};

char *rec(int y,int x){
	char tmp = mp[y][x];
	if(tmp == '.'){
		char ret[256];
		sprintf(ret,"%d %d",x,y);
		return ret;
	}else if(tmp == 't'){
		char ret[] = "LOOP";
		return ret;
	}
	mp[y][x] = 't';
	int d = dir.find(tmp);
	return rec(y + dy[d],x + dx[d]);
}


int main(void){
	int h, w;
	while(true){
		cin >> h >> w;
		cin.get();
		if(h == 0 && w == 0){
			break;
		}
		for(int i = 0;i < h;i++){
			getline(cin,mp[i]);
		}
		cout << rec(0,0) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int *array1, *array2, n, m, tmp, i, j;
	char w;
	
	while(1){
		cin >> n >> m;
		if(n == 0 || m == 0){
			break;
		}
		if(n*m > 2){
			array1 = (int *)calloc(n*m, sizeof(int));
			array2 = (int *)calloc(n*m, sizeof(int));
		} else {
			array1 = (int *)calloc(2, sizeof(int));
			array2 = (int *)calloc(2, sizeof(int));
		}
		
		for(i = 0; i < n; i++){
			for(j = 0, tmp = i*m; j < m; j++){
				cin >> w;
				if(tmp < 0){
				break;
				}
				if(w == '>'){
					array1[tmp+j] = tmp + j + 1;
				} else if(w == 'v'){
					array1[tmp+j] = tmp + j + m;
				} else if(w == '<'){
					array1[tmp+j] = tmp + j -1;
				} else if(w == '^'){
					array1[tmp+j] = tmp + j - m;
				} else {
					array1[tmp+j] = -1;
				}
			}
			if(tmp < 0){
				break;
			}
		}
		if(tmp < 0){
			cout << "LOOP" << endl;
			free(array1);
			free(array2);
			continue;
		}
		
		tmp = array1[0];
		array2[0] = 1;
		while(1){
			if(array2[tmp] == 1){
				cout << "LOOP" << endl;
				break;
			} else if(array1[tmp] == -1){
				i = tmp % m;
				j = (int)(tmp / m);
				cout << i << " " << j << endl;
				break;
			}
			
			array2[tmp] = 1;
			tmp = array1[tmp];
		}		
		
		free(array1);
		free(array2);
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

string s[100];
bool used[100][100];
int h, w;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	while(cin >> h >> w, h) {
		rep(i, h) {
			cin >> s[i];
			rep(j, w) used[i][j] = false;
		}

		int x = 0, y = 0, f = 0;
		while(!used[x][y]) {
			used[x][y] = 1;
			if(s[x][y] == '.') {
				f = 1;
				cout << y << " " << x << endl;
				break;
			}
			int r = (s[x][y] == '>' ? 0 : s[x][y] == '<' ? 2 : s[x][y] == 'v' ? 1 : 3);
			x += dx[r];
			y += dy[r];
		}
		if(!f) cout << "LOOP" << endl;
	}
	return 0;
}

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

int main(void)
{
	while(1) {
		char point[100][100];
		bool check[100][100], ep = false;
		int Y, X;
		int x, y;

		for(int i = 0; i < 100; i++) {
			for(int j = 0; j < 100; j++) {
				point[i][j] = '.';
				check[i][j] = false;
			}
		}

		cin >> Y >> X;

		if(Y == 0 && X == 0) break;

		for(int i = 0; i < Y; i++) {
			for(int j = 0; j < X; j++) {
				cin >> point[j][i];
			}
		}

		x = 0, y = 0;

		while(1) {
			if(check[x][y] == true) {
				cout << "LOOP" << endl;
				break;
			} else {
				check[x][y] = true;

				switch(point[x][y]) {
				case '>' : x += 1; break;
				case '<' : x -= 1; break;
				case '^' : y -= 1; break;
				case 'v' : y += 1; break;
				case '.' : ep = true; break;
				};

				if(ep == true) {
					cout << x << " " << y << endl;
					break;
				}
			}
		}
	}
	return 0;
}