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 <iostream>
#include <vector>
#include <string>
using namespace std;
int main( void )
{
	while ( 1 )
	{
		int w, h;
		cin >> h >> w;
		if ( w == 0 && h == 0 )
			break;

		vector <string> data;
		for ( int i = 0; i < h; i++ )
		{
			string line;
			cin >> line;
			data.push_back( line );
		}

		bool loop_flag = false;
		int x = 0;
		int y = 0;
		while ( 1 )
		{
			int oldx = x;
			int oldy = y;
			if ( data[y][x] == '.' )
				break;
			else if ( data[y][x] == '>' )
				x++;
			else if ( data[y][x] == 'v' )
				y++;
			else if ( data[y][x] == '^' )
				y--;
			else if ( data[y][x] == '<' )
				x--;
			else if ( data[y][x] == 'x' )
			{
				loop_flag = true;
				break;
			}
			data[oldy][oldx] = 'x';
		}

		if ( loop_flag )
			cout << "LOOP" << endl;
		else
			cout << x << " " << y << endl;

	}
	return 0;
}

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

using namespace std;

int main(){
	int n,m,k,l,b[105][105]={0};
	char a[105][105];
	while(1){
		scanf("%d %d",&n,&m);
		if( n==0 && m==0 ) break;
		k=0; l=0;
		for(int i=0 ; i<n ; i++ ){
			scanf("%s",&a[i]);	
		}
		while(1){
			if(a[k][l]=='.'){
				printf("%d %d\n",l,k);
				break;
			}
			if(b[k][l]==1){
				printf("LOOP\n");
				break;
			}
			if(a[k][l]=='>'){
				b[k][l]=1;
				l++;
				continue;
			}
			if(a[k][l]=='v'){
				b[k][l]=1;
				k++;
				continue;
			}
			if(a[k][l]=='<' ){
				b[k][l]=1;
				l--;
				continue;
			}
			if(a[k][l]=='^' ){
				b[k][l]=1;
				k--;
				continue;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

void solve105(int H, int W) {
    vector<vector<int>> visited(H, vector<int>(W,0));
    vector<vector<char>> floor(H, vector<char>(W,0));
    string s;
    REP(i,H) {
        cin >> s;
        REP(j,W) {
            floor[i][j] = s[j];
        }
    }
    int x = 0; int y = 0;
    while (floor[y][x] != '.') {
        if (visited[y][x]) {
            cout << "LOOP" << endl;
            return;
        }
        visited[y][x] = 1;
        if (floor[y][x] == '>') {
            x++;
        }else if (floor[y][x] == '<') {
            x--;
        }else if (floor[y][x] == 'v') {
            y++;
        }else {
            y--;
        }
    }
    cout << x << " " << y << endl;
}

int main() {
    int H, W;
    while (cin >> H >> W, H + W) {
        solve105(H, W);
    }
}

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

using namespace std;

int main(){
	int n,m,k,l,b[105][105]={0};
	char a[105][105];
	while(1){
		scanf("%d %d ",&n,&m);
		if( n==0 && m==0 ) break;
		k=0; l=0;
		for(int i=0 ; i<n ; i++ ){
			scanf("%s",&a[i]);	
		}
		while(1){
			if(a[k][l]=='.'){
				printf("%d %d\n",l,k);
				break;
			}
			if(b[k][l]==1){
				printf("LOOP\n");
				break;
			}
			if(a[k][l]=='>'){
				b[k][l]=1;
				l++;
				continue;
			}
			if(a[k][l]=='v'){
				b[k][l]=1;
				k++;
				continue;
			}
			if(a[k][l]=='<' ){
				b[k][l]=1;
				l--;
				continue;
			}
			if(a[k][l]=='^' ){
				b[k][l]=1;
				k--;
				continue;
			}
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int status[102][102];
char field[102][102];
void serch(int h,int w)
{
    if(status[h][w]==1)cout<<"LOOP"<<endl;
    else{
        status[h][w]++;
        if(field[h][w]=='>')serch(h,w+1);
        else if(field[h][w]=='<')serch(h,w-1);
        else if(field[h][w]=='v')serch(h+1,w);
        else if(field[h][w]=='^')serch(h-1,w);
        else cout<<w<<" "<<h<<endl;
    }
}
int main()
{
    int H,W;
    while(cin>>H>>W&&H!=0){
        for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                        status[i][j]=0;
                        cin>>field[i][j];
                }
        }
        serch(0,0);
    }
}

C++: #include <cstdio>

using namespace std;

int main()
{
	int h, w;
	char str[100][100];
	
	while (scanf("%d %d", &h, &w), !(h == 0 && w == 0)){
		bool flag = true;
		
		for (int i = 0; i < h; i++){
			scanf("%s", str[i]);
		}
		int x = 0, y = 0;
		while (str[y][x] != '.'){
			
			if (str[y][x] == 'l'){
				flag = false;
				break;
			}
			if (str[y][x] == '>'){
				str[y][x] = 'l';
				x++;
			}
			else if (str[y][x] == '<'){
				str[y][x] = 'l';
				x--;
			}
			else if (str[y][x] == '^'){
				str[y][x] = 'l';
				y--;
			}
			else if (str[y][x] == 'v'){
				str[y][x] = 'l';
				y++;
			}
		}
		if (flag){
			printf("%d %d\n", x, y);
		}
		else {
			printf("LOOP\n");
		}
	}
}

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