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

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

#define POS y*w+x

int main(){
while(1){
	int w, h;
	string str;
	getline( cin, str );
	sscanf( str.c_str(), "%d %d", &h, &w );
	if( (h==0)&&(w==0) ) break;

	char *data = new char[w*h];
	// data input
	for( int y=0; y<h; y++ ){
		getline( cin, str );
		for( int x=0; x<w; x++ ){
			data[POS] = str.c_str()[x];
		}
	}

	// search
	int p = 0, cnt=0;
	while( data[p] != '.' ){
		switch(data[p]){
		case '>':
			p++;
			break;
		case '<':
			p--;
			break;
		case 'v':
			p+=w;
			break;
		case '^':
			p-=w;
			break;
		}
		cnt++;
		if( cnt > w*h ) break;
	}

	// output
	if( cnt > w*h ){
		cout << "LOOP" << endl;
	}else{
		cout << p%w << " " << p/w << endl;
	}

	delete[] data;
	data = 0;
}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#define W_MAX 100
#define H_MAX 100
char map[H_MAX+1][W_MAX+1];
char gx,gy;
int solve(int posX,int posY)
{
	if(map[posY][posX]=='x')
		return 0;
	map[posY][posX]='x';
	if(map[posY][posX]=='^')
		return solve(posX,posY-1);
	else if(map[posY][posX]=='v')
		return solve(posX,posY+1);
	else if(map[posY][posX]=='>')
		return solve(posX+1,posY);
	else if(map[posY][posX]=='<')
		return solve(posX-1,posY);
	gx=posX;gy=posY;
	return 1;
}
int main(void)
{
	int w,h,k;
	char str[101];
	while(true){
		scanf("%d%d",&h,&w);
		if(h==0||w==0)break;
		for(k=0;k<h;k++)
		{
			scanf("%s",&str);
			strcpy(map[k],str);
		}
		if(solve(0,0)==1)printf("%d %d\n",gx,gy);
		else printf("LOOP\n");
	}
}

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

int main(){

  int h, w, v[100][100], x, y;
  string str[100];

  while(cin >> h >> w){
    if(h == 0) break;
    for(int i=0; i<h; i++){
      fill(&v[i][0], &v[i][w], 0);
    }

    getline(cin, str[0]);
    for(int i=0; i<h; i++){
      getline(cin, str[i]);
    }

    x = 0;
    y = 0;
    while(1){
      if(str[x][y] == '.'){
        cout << y << " " << x << endl;
        break;
      }
      else if(v[x][y] == 1){
        cout << "LOOP" << endl;
        break;
      }

      v[x][y] = 1;      

      if(str[x][y] == '^') x--;
      else if(str[x][y] == '>') y++;
      else if(str[x][y] == 'v') x++;
      else if(str[x][y] == '<') y--;
    }
  }

  return 0;

}

C++: #include <stdio.h>
#define U 1
#define D 2
#define R 3
#define L 4
#define MAX 100

int main(void){
    int dx[L+1] = {0,0,0,1,-1};
    int dy[L+1] = {0,-1,1,0,0};
    int pnl[MAX][MAX];
    int visited[MAX][MAX];
    char buf[MAX+1];
    int h,w,x,y,dir;
    
    while (scanf("%d %d",&h, &w)){
        if (h==0 && w==0) break;
        // load
        for (int i=0; i<h; i++){
            scanf("%s", buf);
            for (int j=0; j<w; j++){
                visited[j][i] = pnl[j][i] = 0;
                switch (buf[j]){
                    case '^' : pnl[j][i]=U; break;
                    case 'v' : pnl[j][i]=D; break;
                    case '>' : pnl[j][i]=R; break;
                    case '<' : pnl[j][i]=L; break;
                }
            }
        }
        // move
        x = y = 0;
        while(pnl[x][y] && !visited[x][y]){
            visited[x][y]=1;
            dir = pnl[x][y];
            x += dx[dir];
            y += dy[dir];
        }
        if (pnl[x][y]){
            printf("LOOP\n");
        } else {
            printf("%d %d\n", x,y);
        }
    }
    
    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
char a[8000][8000]; int h, w, loop, cx, cy;
int main() {
	while (true) {
		cin >> h >> w;
		if (!h) { break; }
		memset(a, ' ', sizeof(a));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> a[i][j];
			}
		}
		cx = 0; cy = 0; loop = 0;
		while (true) {
			if (loop > 15000000) { cout << "LOOP" << endl; break; }
			if (a[cy][cx] == '.') { cout << cx << ' ' << cy << endl; break; }
			if (a[cy][cx] == '<') { cx--; }
			if (a[cy][cx] == '>') { cx++; }
			if (a[cy][cx] == '^') { cy--; }
			if (a[cy][cx] == 'v') { cy++; }
			loop++;
		}
	}
}