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(){
    char a[100][100];
    int h,w,n=0;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    h=0;
    w=0;
    while(true){
        n+=1;
        if(a[w][h]=='.'){
            break;
        }
        if(a[h][w]=='>'){
            w+=1;
        }
        if(a[h][w]=='<'){
            w-=1;
        }
        if(a[h][w]=='^'){
            h-=1;
        }
        if(a[h][w]=='v'){
            h+=1;
        }
        if(n==10001){
            break;
        }
    }
    if(n==10001){
        cout<<"LOOP"<<endl;
    }
    else{
        cout<<w<<" "<<h<<endl;
    }
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n,m;
    bool loop;
    int a,b;

    while(cin >> a >> b, b){
        char map[100][100];
        n = m = 0;
        loop = true;
        rep(i,a){
            rep(j,b){
                cin >> map[i][j];
            }
        }
        for(int k = 0; k < a * b; k++){
            if(map[n][m] == '>')
                m++;
            else if(map[n][m] == '<')
                m--;
            else if(map[n][m] == 'v')
                n++;
            else if(map[n][m] == '^')
                n--;
            else
                loop = false;
        }
        if(loop == false)
            cout << m << " " << n << endl;
        else
            cout << "LOOP" << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main() {
    int h, w;
    char c;
    char map_[101][101];
    while (true) {
        cin >> h >> w;
        if (w == 0) {
            break;
        }
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                cin >> map_[j][i];
            }
        }
        int x = 0;
        int y = 0;
        while (true) {
            if (map_[x][y] == '.') {
                cout << x << ' ' << y << endl;
                break;
            }
            if (map_[x][y] == 'L') {
                cout << "LOOP" << endl;
                break;
            }
            c = map_[x][y];
            map_[x][y] = 'L';
            switch (c) {
                case '>':
                    x++;
                    break;
                case '<':
                    x--;
                    break;
                case 'v':
                    y++;
                    break;
                case '^':
                    y--;
                    break;
            }
        }
    }
    return 0;
}

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

using namespace std;

string a[102];
int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
int X, Y, gx, gy;

int dfs(int y, int x){
  int i;
  if(y < 0 || Y <= y || x < 0 || X <= x || a[y][x] == '.') { gx = x; gy = y; return 0;}
  if(a[y][x] == '#') return 1;
  if(a[y][x] == '^')      i = 0;
  else if(a[y][x] == '>') i = 1;
  else if(a[y][x] == 'v') i = 2;
  else                    i = 3;
  a[y][x] = '#';
  dfs(y + dy[i], x + dx[i]);
}

int main(){
  while(cin >> Y >> X, X != 0 || Y != 0) {
    for(int i = 0; i < Y ; i++)
      cin >> a[i];
    if(dfs(0, 0) == 1)cout << "LOOP" << endl;
    else  cout << gx << ' ' << gy << endl;
  }
}

C++: #include<cstdio>
#include<iostream>
  
using namespace std;
  
int main(void){

	int W,H;
	int x,y;
	bool f;
	char stage[101][101];

	while(1){
		cin>>H>>W;
		if(H==0&&W==0) break;
		getchar();
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				stage[i][j]=getchar();
			}
			getchar();
		}
		x=0,y=0;
		f=true;
		while(f){
			switch(stage[y][x]){
				case '>':
					stage[y][x]='-';
					x+=1;
					break;
				case '<':
					stage[y][x]='-';
					x-=1;
					break;
				case '^':
					stage[y][x]='-';
					y-=1;
					break;
				case 'v':
					stage[y][x]='-';
					y+=1;
					break;
				case '.':
					cout<<x<<" "<<y<<endl;
					f=false;
					break;
				case '-':
					cout<<"LOOP"<<endl;
					f=false;
					break;
				default:
					cout<<"error"<<endl;
					return -1;
			}
		}
	}

	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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

int A = 0, B = 0, C = 0, K = 0, S = 0, T = 0, W = 0, N = 0,H = 0;
int n = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string c;
string sA, strB;
vector<vector<char>> map;
vector<int> population;


void input() {
	CI W >> H;
	
	map.resize(W);
	REP(i, W) {
		map[i].resize(H);
	}
	REP(i, W) {
		REP(j, H) {
			CI map[i][j];
		}
	}
}

void proce() {
	int posn[2] = { 0,0 };
	vector<vector<bool>> check(W, vector<bool>(H, false));
	

	while (map[posn[0]][posn[1]] != '.') {
		check[posn[0]][posn[1]] = true;
		if (map[posn[0]][posn[1]] == '>') {
			posn[1]++;
		}
		else {
			if (map[posn[0]][posn[1]] == 'v') {
				posn[0]++;
			}
			else {
				if (map[posn[0]][posn[1]] == '<') {
					posn[1]--;
				}
				else {
					if (map[posn[0]][posn[1]] == '^') {
						posn[0]--;
					}
				}
			}
		}
		if (check[posn[0]][posn[1]] == true) {
			CO "ROOP" E
			return;
		}
	}
	CO posn[1] << " " << posn[0] E


}

int main(void) {
	
	while (true) {
		input();
		if (W == 0 && H == 0) {
			break;
		}
		proce();
	}

	return 0;
}