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

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <set>
using namespace std;
bool calc(vector<vector<char> >, int y, int x);
int resultx;
int resulty;
set<string> passed;

int main() {
  while(true) {
  int width, height;
  cin >> width >> height;
  if(width == 0 && height == 0) break;
  vector<vector<char> > field(width, vector<char>(height));
  for(int w = 0; w < width; ++w) {
    for(int h = 0; h < height; ++h) {
      cin >> field[w][h];
    }
  }
  if(calc(field, 0, 0)) cout << resulty << " " << resultx << endl;
  }
  return 0;
}

bool calc(vector<vector<char> > field, int y, int x) {
  stringstream ss;
  ss << y << ',' << x;
  // cout << ss.str() << endl;
  if(passed.find(ss.str()) != passed.end()) {
    cout << "LOOP" << endl;
    return false;
  }
  passed.insert(ss.str());
  switch(field[x][y]) {
    case '>':
      calc(field, y + 1, x);
      break;
    case '<':
      calc(field, y - 1, x);
      break;
    case '^':
      calc(field, y, x - 1);
      break;
    case 'v':
      calc(field, y, x + 1);
      break;
    case '.':
      resultx = x;
      resulty = y;
      return true;
  }
}

C++: #include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
 
int main(){
    while(1){
        int h, w;
        char f[102][102];
         
        scanf(" %d %d", &h, &w);
        if(h==0) break;
         
        for(int i=0; i<h; ++i)
        for(int j=0; j<w; ++j)
        scanf(" %c", &f[i][j]);
         
        int x=0, y=0;
        bool loop=false;
        while(!loop && f[y][x]!='.'){
            if(f[y][x]=='a') loop=true;
            else{
                int tx=x, ty=y;
                 
                if(f[y][x]=='>') ++x;
                else if(f[y][x]=='<') --x;
                else if(f[y][x]=='^') --y;
                else if(f[y][x]=='v') ++y;          
                 
                f[ty][tx]='a';
            }
        } 
        if(loop) printf("LOOP\n");
        else printf("%d %d\n", x, y);
    }
}

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

using namespace std;

int H, W;
int ansx, ansy;
int tile[100][100];

void move(int x, int y) {
	int here = tile[y][x];
	tile[y][x] = -1;

	if (here) {
		if (here == -1) {
			ansx = -1;
			ansy = -1;
		}
		else if (here == 1)		move(x+1, y);
		else if (here == 2)	move(x-1, y);
		else if (here == 3) move(x, y-1);
		else				move(x, y+1);
	}
	else {
		ansx = x, ansy = y;
	}

	return;
}

int main() {
	string str;

	while (cin >> H >> W) {
		if (H == 0 && W == 0) break;

		for (int i = 0; i < H; i++) {
			cin >> str;
			
			for (int j = 0; j < W; j++) {
				tile[i][j] = (str[j] == '.') ? 0 : (str[j] == '>') ? 1 : (str[j] == '<') ? 2 : (str[j] == '^') ? 3 : 4;
			}
		}

		move(0, 0);

		if (ansx == -1 && ansy == -1)
			cout << "LOOP" << endl;
		else
			cout << ansx << ' ' << ansy << endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <sstream>
#include <deque>

#define REP(i, n) for ( int i = 0; i < n; i++ )

using namespace std;

void dump(vector<string> f, int x = -1, int y = -1) {
    REP(i, f.size()) {
        REP(j, f[i].size()) {
            if ( i == y && j == x )
                cout << "#";
            else
                cout << f[i][j];
        }
        cout << endl;
    }
}

/*
0:上
1:右
2:下
3:左
*/
int mx[] = {0, 1, 0, -1},
    my[] = {-1, 0, 1, 0};

vector< vector<int> > closed;

void go(vector<string> &f, int x, int y) {
    // dump(f, x, y);
    // cout << endl;

    while( f[y][x] != '.' ) {
        if ( closed[y][x] ) {
            cout << "LOOP" << endl;
            return;
        }
        closed[y][x] = 1;

        int mv = -1;

        switch(f[y][x]) {
            case '^':
                mv = 0;
                break;
            case '>':
                mv = 1;
                break;
            case 'v':
                mv = 2;
                break;
            case '<':
                mv = 3;
                break;
        }
        if ( mv != -1 ) {
            x += mx[mv];
            y += my[mv];
        }
        // dump(f, x, y); cout << endl;
    }
    cout << x << " " << y << endl;
}

int main() {
    int w, h;

    while( cin >> h >> w, w || h ) {
        vector<string> f(h);
        closed = vector< vector<int> >(h, vector<int>(w, 0));

        REP(i, h) {
            REP(j, w) {
                closed[i][j] = 0;
            }
        }

        REP(i, h) {
            cin >> f[i];
        }

        go(f, 0, 0);
    }

    return 0;
}