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>

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

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

typedef std::pair<int,int> coordinate;

int main()
{
	while (true) {
		int H, W;
		std::cin >> H >> W;
		if ( H==0 && W==0 ) break;
		
		std::string* board = new std::string[H];
		for (int i=0; i<H; i++) {
			std::cin >> board[i];
		}
		
		coordinate curr_pos = coordinate(0,0);
		int count = 0;
		while (true) {
			char mark = board[curr_pos.first][curr_pos.second];
			if (mark == '.') {
				std::cout << curr_pos.second << " " << curr_pos.first << std::endl;
				break;
			} else if (mark == '>') {
				curr_pos.second++;
			} else if (mark == '<') {
				curr_pos.second--;
			} else if (mark == '^') {
				curr_pos.first--;
			} else {
				curr_pos.first++;
			}
			count++;
			if (count > H * W) {
				std::cout << "LOOP" << std::endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int c[100][100],a,b,n;
char ch[100][100];
int check(int x,int y){
	c[x][y] = 1;
	switch (ch[x][y]) {
	case '>':
		if (c[x][y+1] == 1) return 1;
		n = check(x,y+1);
		break;
	case '<':
		if (c[x][y-1] == 1) return 1;
		n = check(x,y-1);
		break;
	case 'v':
		if (c[x+1][y] == 1) return 1;
		n = check(x+1,y);
		break;
	case '^':
		if (c[x-1][y] == 1) return 1;
		n = check(x-1,y);
		break;
	case '.':
		a = x;
		b = y;
		return 0;
		break;
	}
	return n;
}
int main(){
	int x,y,i,j;
	while(cin >> x >> y && (x != 0 && y != 0)){
		for(i=0;i<x;i++){
			cin >> ch[i];
		}
		if (check(0,0)) cout << "LOOP" << endl;
		else cout << b << " " << a << endl;
		for(i=0;i<100;i++){
			for(j=0;j<100;j++){
				c[i][j] = 0;
				ch[i][j] = '\0';
			}
		}
	}
	return 0;
}

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

int m,n,w,h;

char b[102][102];
bool v[102][102];

void dfs(int y,int x){
    if(v[y][x]){cout<<"LOOP"<<endl;return;}
    v[y][x]=1;
    if(b[y][x]=='>')
        return dfs(y,x+1);
    if(b[y][x]=='v')
        return dfs(y+1,x);
    if(b[y][x]=='<')
        return dfs(y,x-1);
    if(b[y][x]=='^')
        return dfs(y-1,x);
    if(b[y][x]=='.')
        cout<<x<<" "<<y<<endl;
}
int main(){
    
    while(cin>>h>>w,w||h){
        for(int i=0;i<h;i++)
            cin>>b[i];
        memset(v,0,sizeof(v));
        dfs(0,0);
    }
}