Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	// var w, h int
	for scanner.Scan() {
		// fmt.Scanf("%d %d", &w, &h)

		input := strings.Split(scanner.Text(), " ")
		w, _ := strconv.Atoi(input[0])
		h, _ := strconv.Atoi(input[1])

		if w == 0 && h == 0 {
			return
		}

		isArrive := make([][]bool, w)
		tiles := make([][]string, w)

		for i := 0; i < w; i++ {
			rowArrive := make([]bool, h)
			rowTiles := make([]string, h)
			scanner.Scan()
			row := scanner.Text()
			for j := 0; j < h; j++ {
				rowTiles[j] = string(row[j])
			}
			tiles[i] = rowTiles
			isArrive[i] = rowArrive
		}

		var i, j int
		isEnd := false
		for {
			if isArrive[i][j] == true {
				fmt.Println("LOOP")
				break
			}
			isArrive[i][j] = true

			switch tiles[i][j] {
			case ">":
				j++
			case "^":
				i--
			case "v":
				i++
			case "<":
				j--
			case ".":
				isEnd = true
			}

			if isEnd == true {
				fmt.Println(j, i)
				break
			}
		}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
typedef int  i32;
typedef long long i64,ll;
#define BR "\n"

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef MODE_DEBUG
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl

#define  DUMP(x)  cerr << #x << " = " << (x) <<endl
#define DEBUG(x) DUMP(x) << " (L" << __LINE__ << ")" << " " << __FILE__<<endl
#define CHECK(exp,act)  if(exp!=act){DUMP(exp);DEBUG(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#else
#define DUMP(x)
#define DEBUG(x)
#define CHECK(exp,act)
#define STOP(e)
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}
template<class T> inline string toString(const vector<vector<T>>& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

int main(){
	while(true){
		int H,W;cin >> H >> W;
		if(H==0 && W==0)break;
		vector<string> map=vector<string>(H);
		REP(i,H)cin >> map[i];
		vector<vector<bool>> passed=vector<vector<bool>>(H,vector<bool>(W));

		int px=0,py=0;
		while(true){
			if(map[py][px]=='.'){
				cout << px <<" "<<py <<endl;break;
			}
			if(passed[py][px]){
				cout <<"LOOP"<<endl;break;
			}
			passed[py][px]=true;
			switch(map[py][px]){
				case '>':px++;break;
				case '<':px--;break;
				case '^':py--;break;
				case 'v':py++;break;
			}
		}
	}

	return 0;
}

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

int m,n,w,h;
char b[102][102];
bool v[102][102];

void dfs(int y,int x){
    if(v[y][x]){
        cout<<"LOOP"<<endl;
        return;
    }
    v[y][x]=1;
    if(b[y][x]=='>'){
        dfs(y,x+1);
        //return;
    }
    if(b[y][x]=='v'){
        dfs(y+1,x);
        //return;
    }
    if(b[y][x]=='<'){
        dfs(y,x-1);
        //return;
    }
    if(b[y][x]=='^'){
        dfs(y-1,x);
        //return;
    }
    cout<<x<<" "<<y<<endl;
}

int main(){
    while(cin>>h>>w,w||h){
        for(int i=0;i<h;i++)
            cin>>b[i];
        memset(v,0,sizeof(v));
        dfs(0,0);
    }
}

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

char ma[100][100];
bool visited[100][100];

int main() {
  int w,h;
  string s;
  while(cin>>w>>h, w|h) {
    for(int i=0; i<w; ++i) {
      cin>>s;
      for(int j=0; j<h; ++j) {
	ma[i][j] = s.at(j);
	visited[i][j] = false;
      }
    }

    int nx=0, ny=0;
    while(1) {
      if(visited[nx][ny]) {
	cout<<"LOOP"<<endl;
	break;
      }
      visited[nx][ny] = true;
      if(ma[nx][ny] == '.') {
	cout<<ny<<" "<<nx<<endl;
	break;
      }
      if(ma[nx][ny] == '>') ny++;
      if(ma[nx][ny] == '<') ny--;
      if(ma[nx][ny] == '^') nx--;
      if(ma[nx][ny] == 'v') nx++;
    }
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

string data[500];
bool sumi[500][500];
int nx,ny,ansx,ansy;
int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h==0&&w==0) break;
		REP(i,h) cin >> data[i];
		REP(i,500) REP(j,500) sumi[i][j] = false;
		nx = 0; ny = 0;
		bool flg = true;

		sumi[nx][ny] = true;
		while(flg){
			if(data[nx][ny]=='>') ny++;
			if(data[nx][ny]=='<') ny--;
			if(data[nx][ny]=='^') nx--;
			if(data[nx][ny]=='v') nx++;
			if(data[nx][ny]=='.'){
				ansx = nx;
				ansy = ny;
				flg = false;
			}
			if(sumi[nx][ny]){
				ansx = -1;
				flg = false;
			}
			sumi[nx][ny] = true;
		}
		if(ansx==-1) cout << "LOOP" << endl;
		else cout << ansy << " " << ansx << endl;
	}
}

C++: #include<cstdio>
using namespace std;
int g_x,g_y;
char field[100][100];
void solve(int y,int x);
int main(){

    int h,w;
    while(scanf("%d %d",&h,&w),!h==0 && !w==0){
        for(int i=0;i<h;i++){
            scanf("%s",field[i]);
        }
        solve(0,0);
        if(g_x==0 && g_y==0)puts("LOOP");
        else printf("%d %d\n",g_x,g_y);
    }
    return 0;

}

void solve(int y,int x){
    if(field[y][x]=='0'){
        g_x=g_y=0;
        return;
    }
    if(field[y][x]=='.'){
        g_x=x;
        g_y=y;
        return;
    }
    if(field[y][x]=='>'){
        field[y][x]='0';
        solve(y,x+1);
    }
    if(field[y][x]=='<'){
        field[y][x]='0';
        solve(y,x-1);
    }
    if(field[y][x]=='^'){
        field[y][x]='0';
        solve(y-1,x);
    }
    if(field[y][x]=='v'){
        field[y][x]='0';
        solve(y+1,x);
    }
}