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<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

string mt[200];
int used[200][200];

int main() {
	int h,w;
	while(~scanf("%d %d\n",&h,&w),h){
		int x,y;
		for(y=0;y<h;y++){
			cin>>mt[y];
		}
		memset(used,0,sizeof(used));
		pint pos(0,0);
//cout<<"hoge"<<endl;
//cout<<mt[0][0]<<endl;
//cout<<'>'<<endl;
		while(mt[pos.second][pos.first]!='.'){
//cout<<pos.first<<" "<<pos.second<<endl;
			if(used[pos.second][pos.first]==1)break;
			used[pos.second][pos.first]=1;
			if(mt[pos.second][pos.first]=='>'){
				pos.first++;
			}else if(mt[pos.second][pos.first]=='<'){
				pos.first--;
			}else if(mt[pos.second][pos.first]=='v'){
				pos.second++;
			}else{
				pos.second--;
			}
		}
		if(mt[pos.second][pos.first]!='.')cout<<"LOOP";
		else cout<<pos.first<<" "<<pos.second<<endl;
	}
	return 0;
}

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

int main() {
    int H, W;
    
    while (cin >> H >> W && H + W != 0) {
        cin.get();
        
        char room[101][101];

        for (int h = 0; h < H; ++h) {
            for (int w = 0; w < W; ++w) {
                cin >> room[h][w];
            }
        }

        int x = 0, y = 0;
        bool loop = false;

        while (room[x][y] != '.' && !loop) {
            switch (room[x][y]) {
                case '!':
                    loop = true;
                    break;
                case '>':
                    room[x][y] = '!';
                    y++;
                    break;
                case '<':
                    room[x][y] = '!';
                    y--;                
                    break;
                case '^':
                    room[x][y] = '!';
                    x--;    
                    break;
                case 'v':
                    room[x][y] = '!';
                    x++;  
                    break;
            }
        }

        if (loop) {
            cout << "LOOP" << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }

    return 0;
}

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

int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0) return 0;
    char a[h][w];
    for (int i = 0; i < h; i++)
      scanf("%s", a[i]);

    int x, y, count;
    x = y = 0;
    count = 0;
    while (true) {
      if (count > 10000) {
	cout << "LOOP" << endl;
	goto loop_end;
      }
      if (a[y][x] == '>') x++;
      else if (a[y][x] == '<') x--;
      else if (a[y][x] == '^') y--;
      else if (a[y][x] == 'v') y++;
      else break;
      count++;
    }
    cout << x << ' ' << y << endl;
  loop_end: ;
  }
}

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

int main() {
  int x, y, mapx, mapy, tmp0, tmp1, flag;
  char map[101][101], pmap;
  scanf("%d%d",&mapx,&mapy);
  while (mapx+mapy) {
    for (tmp0 = 0;tmp0 < mapx;tmp0++) scanf("%s", map[tmp0]);
    x = 0, y = 0, flag = 1;
    while (flag && flag != 100) {
      pmap = map[x][y];
      map[x][y] = 1;
      if (pmap == '>') y++;
      else if (pmap == '<') y--;
      else if (pmap == '^') x--;
      else if (pmap == 'v') x++;
      else if (pmap == '.') flag = 0;
      else flag = 100;
    }
    if (flag) puts("LOOP");
    else printf("%d %d\n", y, x);
    scanf("%d%d", &mapx,&mapy);
  }
  return 0;
}

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

int main() {
    int H, W;
    
    while (cin >> H >> W && H + W != 0) {
        char room[101][101];

        for (int h = 0; h < H; ++h) {
                cin >> room[h];
        }

        int steps = 0, x = 0, y = 0;

        while(steps < W*H) {
            if (room[x][y] == '>') y++;
            else if (room[x][y] == '<') y--;
            else if (room[x][y] == '^') x--;
            else if (room[x][y] == 'v') x++;
            else { break; }
            steps++;
        }

        if (steps >= W*H) {
            cout << "LOOP" << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }

    return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int main(){
	int H,W;
	while(cin>>H>>W,H||W){
		char board[120][120];
		for(int i =0; i < H;i++){
			for(int j = 0;j < W;j++){
				cin>>board[i][j];
			}
		}
		std::vector<pii> v;
		int y = 0;
		int x = 0;
		int cnt = 0;
		bool flag =true;
		while(1){
			if(cnt>=1000000){
				flag =false;
				break;
			}
			cnt++;
			if(board[y][x]=='>'){
				x++;
			}else if(board[y][x]=='<'){
				x--;
			}else if(board[y][x]=='^'){
				y--;
			}else if(board[y][x]=='v'){
				y++;
			}else{
				break;
			}
		}
		if(!flag)cout <<"LOOP"<<endl;
		else cout <<x<<" "<<y<<endl;
	}
	return 0;
}