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 <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

typedef pair<int, int> P;

int main() {
	int H, W;
	while (cin >> H >> W && H && W) {
		string *field = new string[H];
		for (int i = 0; i < H; i++)
			cin >> field[i];
		int x = 0, y = 0;
		vector<P> v;
		while (1) {
			v.push_back(make_pair(x, y));
			if (field[y][x] == '>')
				x++;
			if (field[y][x] == '<')
				x--;
			if (field[y][x] == '^')
				y--;
			if (field[y][x] == 'v')
				y++;
			if (field[y][x] == '.') {
				cout << x << " " << y << endl;
				break;
			}
			int loop = 0;
			vector<P>::iterator it = v.begin();
			while (it != v.end()) {
				if (it->first == x && it->second == y) {
					cout << "LOOP" << endl;
					loop = 1;
					break;
				}
				it++;
			}
			if (loop)
				break;
		}
		delete[] field;
	}
	return 0;
}

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

int main()
{
    int h, w;
    char m[100][100];
    bool b[100][100];

    while( cin >> h >> w )
    {
        if( h == 0 && w == 0 )
            break;

        for( int i = 0; i < h; i++ )
            for( int j = 0; j < w; j++ )
            {
                m[i][j] = '.';
                b[i][j] = false;
            }
        for( int i = 0; i < h; i++ )
            for( int j = 0; j < w; j++ )
                cin >> m[i][j];

        int i = 0, j = 0;
        while( m[i][j] != '.' && b[i][j] != true )
        {
            b[i][j] = true;
            if( m[i][j] == '>' )
                j++;
            else if( m[i][j] == '<' )
                j--;
            else if( m[i][j] == '^' )
                i--;
            else if( m[i][j] == 'v' )
                i++;
            else;
        }
        if( b[i][j] == false )
            cout << j << " " << i << endl;
        else
            cout << "LOOP" << endl;
    }    

    return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	char c[110][110] = {};
	int cnt[110][110] = {};
	for (int H, W; cin >> H >> W&&H;) {
		memset(cnt, 0, sizeof(cnt));
		rep(i, 0, H)rep(j, 0, W)cin >> c[i][j];
		int i = 0, j = 0;
		while (true) {
			cnt[i][j]++;
			if (cnt[i][j] > 10) {
				cout << "LOOP" << endl;
				break;
			}
			else {
				bool flag = false;
				switch (c[i][j])
				{
				case '.':
					cout << j << " " << i << endl;
					flag = true;
					break;
				case '>':
					j++;
					break;
				case '<':
					j--;
					break;
				case '^':
					i--;
					break;
				case 'v':
					i++;
					break;
				default:
					break;
				}
				if (flag)break;
			}
		}
	}
	return 0;
}

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


int walk(int, int);
char f[100][100];
int H, W;

int main(void){
	while (cin >> H >> W, (H || W)){
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> f[i][j];
			}
		}
		walk(0, 0);
	}
}

int walk(int y, int x){
	switch (f[x][y]){
	case '.':
		printf("%d %d\n", y, x);
		break;
	case 'v':
		f[x][y]= 'a';
		walk(y, x+1);
		break;
	case '^':
		f[x][y] = 'a';
		walk(y, x-1);
		break;
	case '>':
		f[x][y] = 'a';
		walk(y+1, x);
		break;
	case '<':
		f[x][y] = 'a';
		walk(y-1, x);
		break;
	case 'a':
		printf("LOOP\n");
		break;

	}

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

char tile[101][101];

void loop(int x,int y){
	if(tile[x][y]=='.'){
		cout << y << ' ' << x << endl;
		return;
	}
	if(tile[x][y]=='#'){
		cout << "LOOP" << endl;
		return;
	}
	if(tile[x][y]=='>'){
		tile[x][y]='#';
		loop(x,y+1);
	}
	if(tile[x][y]=='<'){
		tile[x][y]='#';
		loop(x,y-1);
	}
	if(tile[x][y]=='^'){
		tile[x][y]='#';
		loop(x-1,y);
	}
	if(tile[x][y]=='v'){
		tile[x][y]='#';
		loop(x+1,y);

	}
}

int main(void){
	int h,w;
	int x,y;
	int a;
	while(1){
		x=0,y=0;
		cin >> h >> w;
		if(h==0 && w==0)break;
		for(a=0;a<h;a++){
			cin >> tile[a];
		}
		loop(0,0);
	}
	return 0;
}

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

char board[100][100];
int boardf[100][100];


void search(int a,int b){
	if(boardf[a][b] == 1){
		cout << "LOOP" << endl;
		return ;
	}
	boardf[a][b] = 1;
	if(board[a][b] == '.'){
		cout << b << " " << a << endl;
		return;
	}
	if(board[a][b] == '>'){
		search(a,b+1);
	}else if(board[a][b] == '<'){
		search(a,b-1);
	}else if(board[a][b] == '^'){
		search(a-1,b);
	}else if(board[a][b] == 'v'){
		search(a+1,b);
	}
}

int main(){
	int a,b;
	char c;
	while(cin >> a >> b){
		if(a==0&&b==0){
			return 0;
		}
		
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				boardf[i][j] = 0;
			}
		}
		
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				cin >> c;
				board[i][j] = c;
			}
		}		
		
		search(0,0);

		/*for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				cout << board[i][j] << " ";
			}
			cout << endl;
		}*/		
	}
	return 0;
}