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 <bits/stdc++.h>

using namespace std;

int h, w;
char field[100][101];

void solve(int x, int y){

    switch(field[y][x]){

        case '>':
            field[y][x] = 'x';
            solve(x + 1, y);
            return;

        case '<':
            field[y][x] = 'x';
            solve(x - 1, y);
            return;

        case '^':
            field[y][x] = 'x';
            solve(x, y - 1);
            return;

        case 'v':
            field[y][x] = 'x';
            solve(x, y + 1);
            return;

        case '.':
            cout << x << ' ' << y << endl;
            return;

        case 'x':
            cout << "LOOP" << endl;
            return;

    }

}

int main(){

    cin >> h >> w;

    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
            cin >> field[i][j];

    solve(0, 0);

}

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

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

	int H, W;
	while (cin >> H >> W , H) {
		string b[101];
		for (int i = 0; i < H; i++) {
			cin >> b[i];
		}

		bool visited[101][101] = {false};
		int x = 0, y = 0;
		while (b[y][x] != '.' && !visited[y][x]) {
			visited[y][x] = true;
			if (b[y][x] == '^') y--;
			if (b[y][x] == 'v') y++;
			if (b[y][x] == '<') x--;
			if (b[y][x] == '>') x++;
		}

		if (visited[y][x]) {
			cout << "LOOP" << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}
}

C++: #include <algorithm>
#include <cmath>
#include <ctime>
#include <climits>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>

using namespace std;

int main() {
    int H, W;
    while (cin >> H >> W && (H || W)) {
        vector<string> tiles(H, string(W, ' '));
        for (int i=0; i<H; ++i) {
            for (int j=0; j<W; ++j) {
                cin >> tiles[i][j];
            }
        }

        int x = 0, y = 0;
        int visited[101][101] = {false};
        while ( ! visited[y][x]) {
            visited[y][x] = true;
            switch (tiles[y][x]) {
                case '>':
                    x ++;
                    break;
                case '<':
                    x --;
                    break;
                case 'v':
                    y ++;
                    break;
                case '^':
                    y --;
                    break;
            }
        }
        if (tiles[y][x] == '.') {
            cout << x << " " << y << endl;
        } else {
            cout << "LOOP" << 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+1, sizeof(int));
			array2 = (int *)calloc(n*m+1, 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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

string comp(int x, int y)
{
	stringstream ss;

	ss << x << " " << y;

	return ss.str();
}

string rec(vector<string>& field, pint pos)
{
	int buf = field[pos.first][pos.second];
	field[pos.first][pos.second] = 0;
	
	switch(buf)
	{
	case '.' :
		return comp(pos.second, pos.first);
		
	case '>' :
		return rec(field, mp(pos.first, pos.second + 1));

	case '<' :
		return rec(field, mp(pos.first, pos.second - 1));

	case '^' :
		return rec(field, mp(pos.first - 1, pos.second));

	case 'v' :
		return rec(field, mp(pos.first + 1, pos.second));

	default :
		return "LOOP";
	}
}

int main()
{
	int w, h;
	while(cin >> h >> w && w)
	{
		vector<string> field(h);

		rep(i, h)
			cin >> field[i];

		cout << rec(field, mp(0, 0)) << endl;
	}
}

C++: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int H, W;
  while (cin >> H >> W, H) {
    string s[110];
    bool used[110][110] = {};
    for (int i = 0; i < H; i++) {
      cin >> s[i];
    }
    int y = 0, x = 0;
    bool loop = false;
    while (true) {
      if (used[y][x]) {
        loop = true;
        break;
      }
      used[y][x] = true;
      if (s[y][x] == '>') x++;
      else if (s[y][x] == '<') x--;
      else if (s[y][x] == '^') y--;
      else if (s[y][x] == 'v') y++;
      else break;
    }
    if (loop) cout << "LOOP" << endl;
    else cout << x << " " << y << endl;
  }

  return 0;
}