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 <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)
{
	string res;

	res += char(x + '0');
	res += " ";
	res += char(y + '0');

	return res;
}

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 <iostream>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;++i)
#define mkp make_pair
#define F first
#define S second
int main(){
	int h,w;
	while(cin>>h>>w,h||w){
		vector<vector<int> > vv(h,vector<int>(w));
		// cout<<vv.size()<<" "<<vv[0].size()<<endl;
		pair<int,int> pos=mkp(0,0);
		vector<string> vs(h);
		rep(i,h){
			rep(j,w){
				vv[i][j]=1;
			}
		}
		rep(i,h) cin>>vs[i];
		bool flag=true;
		while(vv[pos.F][pos.S]){
			// cout<<vs[pos.F][pos.S]<<endl;
			vv[pos.F][pos.S]=0;
			int x=pos.F,y=pos.S;
			if(vs[x][y]=='.'){
				cout<<y<<" "<<x<<endl;
				flag=false;
				break;
			}
			if(vs[x][y]=='<') pos.S--;
			else if(vs[x][y]=='>') pos.S++;
			else if(vs[x][y]=='^') pos.F--;
			else pos.F++;
		}
		if(flag) cout<<"LOOP\n";
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

	int w, h;

	while(cin >> w >> h) {
		if(!w&&!h) {
			break;
		}
		char s[100][100];
		for(int i=0; i<w; i++) {
			for(int j=0; j<h; j++) {
				cin >> s[i][j];
			}
		}
		int c=0, x=0, y=0;
		while(c<w*h) {
			(s[x][y]=='>') && y++;
			(s[x][y]=='<') && y--;
			(s[x][y]=='^') && x--;
			(s[x][y]=='v') && x++;
			if(s[x][y]=='.') {
				break;
			}
			c++;
		}
		if(c!=w*h) {
			cout << y << " " << x << endl;
		}
		else {
			cout << "LOOP" << endl;
		}
	}

	return 0;

}

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

using namespace std;

char field[110][110];
int used[110][110];

void f(int y, int x) {
    if (field[y][x] == '.') {
        printf("%d %d\n", x, y);
        return;
    }
    if (used[y][x]) {
        puts("LOOP");
        return;
    }

    used[y][x] = 1;
    switch (field[y][x]) {
        case '>': f(y, x + 1); break;
        case 'v': f(y + 1, x); break;
        case '<': f(y, x - 1); break;
        case '^': f(y - 1, x); break;
    }
}

int main(void) {
    int H, W;
    while (scanf("%d %d", &H, &W), H) {
        for (int i = 0; i < H; i++) {
            scanf("%s", field[i]);
            for (int j = 0; j < W; j++)
                used[i][j] = 0;
        }
        
        f(0, 0);
    }
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

P move(char** stage){
	set<P> visited;
	int c=1;
	int x=0,y=0;

	visited.insert(P(x,y));

	while(1){
		if(stage[y][x] == '>') x++;
		else if(stage[y][x] == '^') y--;
		else if(stage[y][x] == '<') x--;
		else if(stage[y][x] == 'v') y++;
		else if(stage[y][x] == '.') break;

		visited.insert(P(x,y));
		if(++c != visited.size()) return P(-1,-1);
	}

	return P(x,y);
}

int main(){

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

		char** stage = new char*[h];
		for(int i=0;i<h;i++) stage[i] = new char[w];

		for(int y=0;y<h;y++){
			getline(cin,str);
			for(int x=0;x<w;x++){
				stage[y][x] = str[x];
			}
		}

		P pos = move(stage);

		if(pos.first == -1 && pos.second == -1) cout << "LOOP" << endl;
		else printf("%d %d\n",pos.first,pos.second);

		for(int i=0;i<h;i++) delete[] stage[i];
		delete[] stage;
	}
}

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


char tile[100][100];
int h, w;
int ax, ay;
bool loop = false;


void solve(int x, int y){
	if (tile[y][x] == '>'){
		tile[y][x] = '*';
		solve(x + 1, y);
	}
	else if (tile[y][x] == '<'){
		tile[y][x] = '*';
		solve(x - 1, y);
	}
	else if (tile[y][x] == '^'){
		tile[y][x] = '*';
		solve(x, y - 1);
	}
	else if (tile[y][x] == 'v'){
		tile[y][x] = '*';
		solve(x, y + 1);
	}
	else if (tile[y][x] == '.'){
		ax = x;
		ay = y;
	}
	else if (tile[y][x] == '*'){
		loop = true;
	}
}


int main(){


	while (cin >> h >> w, h || w != 0){
		for (int y = 0; y < h; y++){
			for (int x = 0; x < w; x++){
				cin >> tile[y][x];
			}
		}
		solve(0, 0);
		if (!loop) cout << ax << ' ' << ay << endl;
		else cout << "LOOP" << endl;
	}

	return 0;
}

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

template <typename T>
auto move (T & a, int & x , int & y) -> bool
{
    while (true)
    {
        switch (a [y] [x])
        {
        case '>' :
            a [y] [x] = 'x';
            ++ x;
            break;
        case '<' :
            a [y] [x] = 'x';
            -- x;
            break;
        case '^' :
            a [y] [x] = 'x';
            -- y;
            break;
        case 'v' :
            a [y] [x] = 'x';
            ++ y;
            break;
        case '.' :
            return true;
        case 'x' :
            return false;
        }
    }
}

auto main () -> int
{
    int h , w;
    while (std::cin >> h >> w && h && w)
    {
        std::vector <std::vector <char>> a (h , std::vector <char> (w));
        for (auto && line : a)
        {
            for (auto && elem : line)
            {
                std::cin >> elem;
            }
        }

        int x = 0 , y = 0;
        if (move (a , x , y))
        {
            std::cout << x << ' ' << y << std::endl;
        }
        else
        {
            std::cout << "LOOP" << std::endl;
        }
    }
}