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++: //#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

string s[105];
bool used[105][105];
signed main(void)
{
  while(true) {
    int h, w;
    cin >> h >> w;
    if(!h && !w) break;
    REP(i, h) cin >> s[i];

    int x = 0, y = 0;
    memset(used, false, sizeof(used));
    while(true) {
      if(used[y][x]) {
        cout << "LOOP" << endl;
        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 {
        cout << x << " " << y << endl;
        break;
      }
    }
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(void){
	while(true){
		int x,y;
		int moved = 0;
		bool bLoop = false;
		int h,w;
		char **map;

		cin >> h >> w;
		if( h==0&&w==0 ) break;
		cin.ignore(3,'\n');

		map = new char*[h];
		for(int i = 0; i < h; i++){
			map[i] = new char[w+2];
			cin.getline(map[i], w+2);
		}

		x = 0; y = 0;
		while( true ){
			if( map[y][x] == '.' || bLoop ) break;
			if( moved > h * w + 1 ) bLoop = true;
			switch( map[y][x] ){
				case '>':
					x++;
					break;
				case 'v':
					y++;
					break;
				case '^':
					y--;
					break;
				case '<':
					x--;
					break;
			}
			moved++;
		}
		if( bLoop ) cout << "LOOP\n";
		else cout << x << ' ' << y << '\n';

		for(int i = 0; i < h; i++){
			delete []map[i];
		}
		delete []map;
	}
	return 0;
}

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

int main(void){
	char array[100][100];
	int i,j,w,h;
	while(1){
		cin >> w;
		cin >> h;
		if(w == 0 || h == 0) break;
		for(i=0;i<w;i++) for(j=0;j<h;j++) cin >> array[i][j];		
		i=0;j=0;
		while(1){
			if(array[i][j] == '>'){ array[i][j] = '/'; j++;}
			else if(array[i][j] == '<'){ array[i][j] = '/'; j--;}
			else if(array[i][j] == '^'){ array[i][j] = '/'; i--;}
			else if(array[i][j] == 'v'){ array[i][j] = '/'; i++;}
			else break;
		}
		if(array[i][j] == '/'){ cout << "LOOP" << endl; }
		else { cout << j << " " << i << endl; }
	}
	return 0;
}

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

struct zahyou{
	int x;
	int y;
};

int main(){
	
	int tx,ty,count;
	char map[100][100];
	bool flag;
	struct zahyou now;
	
	
	
	while(cin>>tx>>ty,tx&&ty){
		
		flag=false;
		now.x=0;
		now.y=0;
		memset(map,'\0',sizeof(map));
		
		for(int i=0;i<ty;i++){
			for(int j=0;j<tx;j++){
				cin>>map[i][j];
			}
		}
		
		while(1){

			if(map[now.y][now.x]=='.'){
				cout<<now.x<<" "<<now.y<<endl;
				break;
			}
			else if(map[now.y][now.x]=='1'){
				cout<<"LOOP"<<endl;
				break;
			}

			if(map[now.y][now.x]=='>'){
				map[now.y][now.x]='1';
				now.x++;
			}
			else if(map[now.y][now.x]=='<'){
				map[now.y][now.x]='1';
				now.x--;
			}
			else if(map[now.y][now.x]=='v'){
				map[now.y][now.x]='1';
				now.y++;
			}
			else if(map[now.y][now.x]=='^'){
				map[now.y][now.x]='1';
				now.y--;
			}
		}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int h,w;
  while(cin>>h>>w,h+w) {
    char ba[w][h];
    REP(y,h) {
      REP(x,w) {
        cin >> ba[x][y];
      }
    }
    int x = 0, y = 0;
    int dx[] = {0,1,0,-1};
    int dy[] = {-1,0,1,0};
    char aa[] = {'^','>','v','<'};
    map<char,int> hoge;
    REP(i,4)
      hoge[aa[i]] = i;
    int f[w][h];
    memset(f,0,sizeof(f));
    while(true) {
      printf("%d,%d \n",x,y);
      if (f[x][y]) break;
      if (ba[x][y] == '.') break;

      f[x][y]=1;
      int aa = hoge[ba[x][y]];
      x += dx[aa];
      y += dy[aa];
    }
    if (f[x][y]) cout << "LOOP" << endl;
    else cout << x << " " << y << endl;
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
bool ariv[101][101];
P end(vector<string> grid,int x, int y){
  if(ariv[y][x]) return P(-1,-1);
  else ariv[y][x] = true;
  if(grid[y][x]=='.') return P(x,y);
  if(grid[y][x]=='>') return end(grid,x+1,y);
  if(grid[y][x]=='<') return end(grid,x-1,y);
  if(grid[y][x]=='^') return end(grid,x,y-1);
  if(grid[y][x]=='v') return end(grid,x,y+1);
}
void outp(vector<string> grid,int x,int y){
 P point = end(grid,x,y);
 if(point.first==-1) cout<<"LOOP"<<endl;
 else printf("%d %d\n",point.first,point.second);
}
int main(void){
  int H,W;
  while(cin>>H>>W){
    if(H==0) break;
    vector<string> grid;
    memset(ariv,0,sizeof(ariv));
    REP(y,H){
      string tmp;
      cin>>tmp;
      grid.push_back(tmp);
    }
    if(grid[0][0]=='.') printf("0 0\n");
    else if(grid[0][0]=='>')outp(grid,1,0);
    else if(grid[0][0]=='<')outp(grid,0,0);
    else if(grid[0][0]=='^')outp(grid,0,0);
    else if(grid[0][0]=='v')outp(grid,0,1);
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int h, w; 
	while (cin >> h >> w) {
		char map[114][514];
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				cin >> map[i][j];
		int i = 0, j = 0;
		for (int p = 1; p <= 10000; p++) {
			if (map[i][j] == '.') {
				cout << j << ' ' << i << endl;
				continue;
			}
			else if (map[i][j] == '>') j++;
			else if (map[i][j] == '<') j--;
			else if (map[i][j] == '^') i--;
			else if (map[i][j] == 'v') i++;
		}
		cout << "LOOP\n";
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
long h,w,a[101][101],f,i,j;
string s[101];
for(;;){
cin>>h>>w;
if(h==0)break;
for(i=0;i<h;i++)cin>>s[i];
for(i=0;i<h;i++)
for(j=0;j<w;j++)a[i][j]=0;
i=j=0;
a[i][j]=1;
for(;;){
if(s[i][j]=='>')j++;
else if(s[i][j]=='<')j--;
else if(s[i][j]=='^')i--;
else if(s[i][j]=='v')i++;
else{f=0;break;}
if(a[i][j]==1){f=1;break;}
a[i][j]=1;
}
if(f==0)cout<<j<<" "<<i<<endl;
else cout<<"LOOP"<<endl;
}
return 0;
}