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 "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

string fie[200]={};


int main(){
    int h,w;
    while(cin>>h>>w){
        if(w==0 && h==0)break;

        rep(i,h){
            cin>>fie[i];
        }

        int y=0,x=0;

        int c=0;
        while(c<1000000){
            c++;
            char ch = fie[y][x];
            if(ch=='>'){
                x++;
            }else if(ch=='<'){
                x--;
            }else if(ch=='^'){
                y--;
            }else if(ch=='v'){
                y++;
            }else break;
        }
        if(c==1000000)cout<<"LOOP"<<endl;
        else cout<<x<<" "<<y<<endl;
    }
}

C++: //Name: Magical Tiles
//Level: 2
//Category: 文字列,メモ化
//Note:

/**
 * 一度通った場所を覚えておきながら移動をシミュレーションする。
 * 同じ場所に2回来た場合、ループしている。
 *
 * オーダーは O(HW)。
 */
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool solve() {
    int H, W;
    cin >> H >> W;
    if(!H && !W) return false;

    vector<string> field(H);
    for(int i = 0; i < H; ++i) {
        cin >> field[i];
    }
    vector<vector<bool>> visited(H, vector<bool>(W, false));
    int r = 0, c = 0;
    bool looped = false;
    while(true) {
        visited[r][c] = true;
        switch(field[r][c]) {
        case '>':
            c++;
            break;
        case '<':
            c--;
            break;
        case '^':
            r--;
            break;
        case 'v':
            r++;
            break;
        default:
            goto end;
        }
        if(visited[r][c]) {
            looped = true;
            break;
        }
    }
end:
    if(looped) cout << "LOOP" << endl;
    else cout << c << ' ' << r << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    while(solve()) ;
    return 0;
}

C++: #include<iostream>

using namespace std;
int H, W;
int x = 0, y = 0;
int rog[100][100];
bool check(){
	if (rog[x][y] == 0){
		cout << "LOOP" << endl;
		return true;
	}
	else{
		return false;
	}
}
int main(){
	char map[100][100];

	while (cin >> H >> W,W+H){

		int x = 0, y = 0;
		map[100][100] = {};
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> map[i][j];
				rog[i][j] = 1;
			}
		}
		while (1){
			if (map[x][y] == '>'){
				x++;
				if (check() == true){ break; }
			}
			else if(map[x][y]=='v'){
				y++;
				if (check() == true){ break; }
			}
			else if (map[x][y] == '<'){
				x--;
				if (check() == true){ break; }
			}
			else if (map[x][y] == '^'){
				y--;
				if (check() == true){ break; }
			}
			else {
				cout << x << " " << y << endl;
				break;
			}
			
			rog[x][y] = 0;

		}
	}
	return 0;
}

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

char board[100][100];
bool hasArrived[100][100];

int main() {
	int h, w;
	while (std::cin >> h >> w, h + w != 0) {
		for (int y = 0; y < h; ++y)
			for (int x = 0; x < w; ++x)
				std::cin >> board[x][y];

		int px = 0, py = 0;
		while (true) {
			if (hasArrived[px][py]) {
				std::cout << "LOOP" << std::endl;
				break;
			}

			hasArrived[px][py] = true;

			if (board[px][py] == '.') {
				std::cout << px << " " << py << std::endl;
				break;
			}
			
			if (board[px][py] == '>')
				++px;
			else if (board[px][py] == '<')
				--px;
			else if (board[px][py] == 'v')
				++py;
			else if (board[px][py] == '^')
				--py;
		}

		std::memset(board, 0, sizeof(board));
	}
}

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;
		count=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]=='>'){
				if(map[now.y][now.x+1]=='<'){
					flag=true;
				}
				else{
					now.x++;
				}
			}
			else if(map[now.y][now.x]=='<'){
				if(map[now.y][now.x-1]=='>'){
					flag=true;
				}
				else{
					now.x--;
				}
			}
			else if(map[now.y][now.x]=='v'){
				if(map[now.y+1][now.x]=='^'){
					flag=true;
				}
				else{
					now.y++;
				}
			}
			else if(map[now.y][now.x]=='^'){
				if(map[now.y-1][now.x]=='v'){
					flag=true;
				}
				else{
					now.y--;
				}
			}
			count++;
			
			if(count>=10e+4){
				flag=true;
			}
			
			if(map[now.y][now.x]=='.' || flag){
				if(flag){
					cout<<"LOOP"<<endl;
				}else{
					cout<<now.x<<" "<<now.y<<endl;
				}
				break;
			}
		}
	}
}

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

int main(){
	int w,h;
	while(cin>>w>>h )
	{
		if(h==0 || w==0)break;
		char mass[102][102];
		bool key[102][102];

		for( int i=0; i<h; i++) {
			for( int j=0; j<w; j++){
				cin>>mass[i][j];
				key[i][j]=false;
			}
		}
		w=0,h=0;
		while(1)
		{
			key[h][w]=true;
			if( mass[h][w] == '>' ) w++;
			else if( mass[h][w] == '<' ) w--;
			else if( mass[h][w] == '^' ) h--;
			else if( mass[h][w] == 'v' ) h++;
			else {
				cout<<w<<" "<<h<<endl;
				break;
			}
			
			if(key[h][w]) {
				puts("LOOP");
				break;
			}
		}
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int h,w;
    
    while(cin>>h>>w){
    if(h==0&&w==0)return 0;
    vector<vector<char>> v(h,vector<char>(w));
    vector<vector<bool>> f(h,vector<bool>(w,false));
    
    rep(i,0,h){
        rep(j,0,w){
            cin>>v[i][j];
        }
    }
    int x=0,y=0;
    
    while(!f[y][x]){
        
        f[y][x]=true;
        if(v[y][x]=='>')x++;
        else if(v[y][x]=='<')x--;
        else if(v[y][x]=='v')y++;
        else if(v[y][x]=='^')y--;
        else if(v[y][x]=='.'){
            cout<<x<<" "<<y<<endl;
            goto AWAY;
        }
        
        
    }
    if(f[y][x])cout<<"LOOP"<<endl;
    AWAY:;
    v.clear();
    f.clear();
    }
    
    return 0;
}