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;

char field[110][110];
int used[110][110];

void f(int y, int x) {
    if (field[y][x] == '.') {
        printf("%d %d\n", x, y);
        return;
    }
    if (used[y][x]) {
        puts("LOOP");
        return;
    }

    used[y][x] = 1;
    switch (field[y][x]) {
        case '>': f(y, x + 1); break;
        case 'v': f(y + 1, x); break;
        case '<': f(y, x - 1); break;
        case '^': f(y - 1, x); break;
    }
}

int main(void) {
    int H, W;
    while (scanf("%d %d", &H, &W), H) {
        for (int i = 0; i < H; i++) {
            scanf("%s", field[i]);
            for (int j = 0; j < W; j++)
                used[i][j] = 0;
        }
        
        f(0, 0);
    }
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

P move(char** stage){
	set<P> visited;
	int c=1;
	int x=0,y=0;

	visited.insert(P(x,y));

	while(1){
		if(stage[y][x] == '>') x++;
		else if(stage[y][x] == '^') y--;
		else if(stage[y][x] == '<') x--;
		else if(stage[y][x] == 'v') y++;
		else if(stage[y][x] == '.') break;

		visited.insert(P(x,y));
		if(++c != visited.size()) return P(-1,-1);
	}

	return P(x,y);
}

int main(){

	string str;
	int h,w;
	while(getline(cin,str)){
		sscanf(str.c_str(),"%d %d",&h,&w);
		if(h==w && h==0) break;

		char** stage = new char*[h];
		for(int i=0;i<h;i++) stage[i] = new char[w];

		for(int y=0;y<h;y++){
			getline(cin,str);
			for(int x=0;x<w;x++){
				stage[y][x] = str[x];
			}
		}

		P pos = move(stage);

		if(pos.first == -1 && pos.second == -1) cout << "LOOP" << endl;
		else printf("%d %d\n",pos.first,pos.second);

		for(int i=0;i<h;i++) delete[] stage[i];
		delete[] stage;
	}
}

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


char tile[100][100];
int h, w;
int ax, ay;
bool loop = false;


void solve(int x, int y){
	if (tile[y][x] == '>'){
		tile[y][x] = '*';
		solve(x + 1, y);
	}
	else if (tile[y][x] == '<'){
		tile[y][x] = '*';
		solve(x - 1, y);
	}
	else if (tile[y][x] == '^'){
		tile[y][x] = '*';
		solve(x, y - 1);
	}
	else if (tile[y][x] == 'v'){
		tile[y][x] = '*';
		solve(x, y + 1);
	}
	else if (tile[y][x] == '.'){
		ax = x;
		ay = y;
	}
	else if (tile[y][x] == '*'){
		loop = true;
	}
}


int main(){


	while (cin >> h >> w, h || w != 0){
		for (int y = 0; y < h; y++){
			for (int x = 0; x < w; x++){
				cin >> tile[y][x];
			}
		}
		solve(0, 0);
		if (!loop) cout << ax << ' ' << ay << endl;
		else cout << "LOOP" << endl;
	}

	return 0;
}

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

template <typename T>
auto move (T & a, int & x , int & y) -> bool
{
    while (true)
    {
        switch (a [y] [x])
        {
        case '>' :
            a [y] [x] = 'x';
            ++ x;
            break;
        case '<' :
            a [y] [x] = 'x';
            -- x;
            break;
        case '^' :
            a [y] [x] = 'x';
            -- y;
            break;
        case 'v' :
            a [y] [x] = 'x';
            ++ y;
            break;
        case '.' :
            return true;
        case 'x' :
            return false;
        }
    }
}

auto main () -> int
{
    int h , w;
    while (std::cin >> h >> w && h && w)
    {
        std::vector <std::vector <char>> a (h , std::vector <char> (w));
        for (auto && line : a)
        {
            for (auto && elem : line)
            {
                std::cin >> elem;
            }
        }

        int x = 0 , y = 0;
        if (move (a , x , y))
        {
            std::cout << x << ' ' << y << std::endl;
        }
        else
        {
            std::cout << "LOOP" << std::endl;
        }
    }
}

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

int main(){
    int h, w;

    while(cin >> h >> w, h != 0 || w != 0){
        char map[h][w];
        int x, y;
        bool loop = false;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cin >> map[j][i];
            }
        }
        x = 0;
        y = 0;
        for(int i=1; i<=10000; i++){
            if(map[x][y] == '!'){
                loop = true;
                break;
            }
            if(map[x][y] == '.'){
                break;
            }
            if(map[x][y] == '>'){
                map[x][y] = '!';
                x++;
            }
            else if(map[x][y] == '<'){
                map[x][y] = '!';
                x--;
            }
            else if(map[x][y] == 'v'){
                map[x][y] = '!';
                y++;
            }
            else if(map[x][y] == '^'){
                map[x][y] = '!';
                y--;
            }
        }
        if(loop) cout << "LOOP" << endl;
        else cout << x << " " << y << endl;
    }
    return 0;
}

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

using namespace std;

const char arrow[] = {'>', '<', 'v', '^'};
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

int main(){
	int H, W;
	while(cin >> H >> W, H+W){
		vector<string> tile(101);
		bool visit[101][101];
		for(int i = 0; i < H; i++){
			cin >> tile[i];
		}
		int x = 0, y = 0;
		while(visit[y][x] != true){
			visit[y][x] = true;
			for(int i = 0; i < 4; i++){
				if(tile[y][x] == arrow[i]){
					x += dx[i];
					y += dy[i];
					break;
				}
			}
		}
		if(tile[y][x] == '.'){
			cout << x << ' ' << y << endl;
		}else{
			cout << "LOOP" << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int loop_counter[100][100]={0};
string board[100];
int loop(int y,int x ){
	loop_counter[y][x]++;
	if(loop_counter[y][x]==2)
		cout<<"LOOP"<<endl;
	else if(board[y][x]=='^')
		return loop(y-1,x);
	else if(board[y][x]=='v')
		return loop(y+1,x);
	else if(board[y][x]=='<')
		return loop(y,x-1);
	else if(board[y][x]=='>')
		return loop(y,x+1);
	else if(board[y][x]=='.')
		cout << x <<" "<<y<<endl;
	return 0;
}
int main(){
	int h,w;
	while(cin >> h >> w){
		if(h==0 && w==0)
			return 0;
		for(int i=0 ; i<h ; i++ )
			cin >> board[i];
		loop(0,0);
	}
}