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>
using namespace std;

int main(){
    int h, w;

    while(cin >> h >> w, h != 0 || w != 0){
        char map[h][w];
        int x, y;
        bool loop = false;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cin >> map[j][i];
            }
        }
        x = 0;
        y = 0;
        for(int i=1; i<=10000; i++){
            if(map[x][y] == '!'){
                loop = true;
                break;
            }
            if(map[x][y] == '.'){
                break;
            }
            if(map[x][y] == '>'){
                map[x][y] = '!';
                x++;
            }
            else if(map[x][y] == '<'){
                map[x][y] = '!';
                x--;
            }
            else if(map[x][y] == 'v'){
                map[x][y] = '!';
                y++;
            }
            else if(map[x][y] == '^'){
                map[x][y] = '!';
                y--;
            }
        }
        if(loop) cout << "LOOP" << endl;
        else cout << x << " " << y << endl;
    }
    return 0;
}

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

using namespace std;

const char arrow[] = {'>', '<', 'v', '^'};
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

int main(){
	int H, W;
	while(cin >> H >> W, H+W){
		vector<string> tile(101);
		bool visit[101][101];
		for(int i = 0; i < H; i++){
			cin >> tile[i];
		}
		int x = 0, y = 0;
		while(visit[y][x] != true){
			visit[y][x] = true;
			for(int i = 0; i < 4; i++){
				if(tile[y][x] == arrow[i]){
					x += dx[i];
					y += dy[i];
					break;
				}
			}
		}
		if(tile[y][x] == '.'){
			cout << x << ' ' << y << endl;
		}else{
			cout << "LOOP" << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int loop_counter[100][100]={0};
string board[100];
int loop(int y,int x ){
	loop_counter[y][x]++;
	if(loop_counter[y][x]==2)
		cout<<"LOOP"<<endl;
	else if(board[y][x]=='^')
		return loop(y-1,x);
	else if(board[y][x]=='v')
		return loop(y+1,x);
	else if(board[y][x]=='<')
		return loop(y,x-1);
	else if(board[y][x]=='>')
		return loop(y,x+1);
	else if(board[y][x]=='.')
		cout << x <<" "<<y<<endl;
	return 0;
}
int main(){
	int h,w;
	while(cin >> h >> w){
		if(h==0 && w==0)
			return 0;
		for(int i=0 ; i<h ; i++ )
			cin >> board[i];
		loop(0,0);
	}
}

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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int h,w;cin>>h>>w,h|w;){
		vs field(h);
		rep(i,h)
			cin>>field[i];
		vvi flg(h,vi(w));
		for(int x=0,y=0;;){
			if(field[y][x]=='.'){
				cout<<x<<" "<<y<<endl;
				break;
			}
			if(flg[y][x]){
				cout<<"LOOP"<<endl;
				break;
			}
			flg[y][x]=true;
			switch(field[y][x]){
				case '^': y--; break;
				case 'v': y++; break;
				case '<': x--; break;
				case '>': x++; break;
			}
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	string date[111];
	int a, b;
	int x, y,loop;
	int date2[111][111];
	while (1) {
		loop = 0;
		for (int i = 0; i <= 101; i++) {
			for (int z = 0; z <= 101; z++) {
				date2[i][z] = 0;
			}
		}
		cin >> a >> b;
		if (a == 0 && b == 0) {
			goto end;
		}
		for (int i = 0; i < a; i++) {
			cin >> date[i];
		}
		x = 0;
		y = 0;
		while (1) {
			if (date[y][x] == '>') {
				if (date2[y][x] == 1) {
					goto b;
				}
				date2[y][x] = 1;
				x = x + 1;
			}
			if (date[y][x] == '<') {
				if (date2[y][x] == 1) {
					goto b;
				}
				date2[y][x] = 1;
				x = x - 1;
			}
			if (date[y][x] == 'v') {
				if (date2[y][x] == 1) {
					goto b;
				}
				date2[y][x] = 1;
				y = y + 1;
			}
			if (date[y][x] == '^') {
				if (date2[y][x] == 1) {
					goto b;
				}
				date2[y][x] = 1;
				y = y - 1;
			}
			if (date[y][x] == '.') {
				goto a;
			}
		}
		b:;
		loop = 1;
		a:;
		if (loop == 1) {
			cout << "LOOP" << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}
end:;
}

C++: #include<iostream>

using namespace std;
int H, W;
int x = 0, y = 0;
int rog[100][100];
bool check(){
	if (rog[x][y] == 0){
		cout << "LOOP" << endl;
		return true;
	}
	
		return false;
	
}
int main(){
	char ma[100][100];

	while (cin >> H >> W,W+H){

		int x = 0, y = 0;
		ma[100][100] = {};
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> ma[j][i];
				rog[j][i] = 1;
			}
		}
		while (1){
			if (ma[x][y] == '>'){
				x++;
				if (check())break; 
			}
			else if(ma[x][y]=='v'){
				y++;
				if (check()) break; 
			}
			else if (ma[x][y] == '<'){
				x--;
				if (check()) break; 
			}
			else if (ma[x][y] == '^'){
				y--;
				if (check())break; 
			}
			else {
				cout << x << " " << y << endl;
				break;
			}
			
			rog[x][y] = 0;

		}
	}
}

C++: #include <iostream>
#include <set>
#define PI pair<int,int>
using namespace std;
char m[101][101];
int main()
{
  int h,w,i,j;
  for(;;){
    cin >> h >> w;
    if(h==0 && w==0) break;
    for(i=0;i<h;i++){
      cin >> m[i];
    }
    i = j = 0;
    set< PI > s;
    s.insert(PI(i,j));
    while(m[i][j] != '.'){
      switch(m[i][j]){
      case '>': j++; break;
      case '<': j--; break;
      case '^': i--; break;
      case 'v': i++; break;
      }
      if(m[i][j] == '.') {
	cout << j << " " << i << endl;
	break;
      }
      if(s.find(PI(i,j)) != s.end()){
	cout << "LOOP" << endl;
	break;
      }
      s.insert(PI(i,j));
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int h,w;
	while(cin>>h>>w,w||h){
		string a;
		for(int i=0;i<w;i++){
			for(int j=0;j<h;j++){
				cin>>a[i][j];
			}
		}
		bool flag=true;
		int i=0,j=0;
		while(flag){
			flag=true;
			if(a[i][j]=='v'){
				i++;
				a[i][j]='!';
			}
			if(a[i][j]=='>'){
				j++;
				a[i][j]='!';
			}
			if(a[i][j]=='<'){
				j--;
				a[i][j]='!';
			}
			if(a[i][j]=='^'){
				i--;
				a[i][j]='!';
			}
			if(a[i][j]=='.'){
				break;
			}
			if(a[i][j]=='!'){
				flag=false;
			}
		}
		if(!flag){
			cout<<"LOOP"<<endl;
		}
		else{
			cout<<j<<' '<<i<<endl;
		}
	}
}