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() {
	int W, H;
	while (cin >> W >> H && W+H!= 0) {
        char room[101][101];

        for (int w = 0; w != W; ++w) {
            cin >> room[w];
        }

        int x = 0, y = 0;
        bool loop = false;

        while (room[x][y] != '.') {
            if (room[x][y] == '>') {
                room[x][y] = 'x';
                y++;
            }
            else if (room[x][y] == '<') {
                room[x][y] = 'x';
                y--;
            }
            else if (room[x][y] == '^') {
                room[x][y] = 'x';
                x--;
            }
            else if (room[x][y] == 'v') {
                room[x][y] = 'x';
                x++;
            }
            else if (room[x][y] == 'x') {
                loop = true;
                break;
            }
        }

        if (loop) {
            cout << "LOOP" << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }
    return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main() {
	map<char, int>mp;
	mp['<'] = 0;
	mp['v'] = 1;
	mp['>'] = 2;
	mp['^'] = 3;
	mp['.'] = 4;
	while (1) {
		int H, W; cin >> H >> W;
		if (!H)break;
		vector<vector<int>>field(H, vector<int>(W));
		for (int i = 0; i < H; ++i) {
			string st; cin >> st;
			for (int j = 0; j < W; ++j) {
				field[i][j] = mp[st[j]];
			}
		}
		int nx = 0;
		int ny = 0;
		for (int i = 0; i < 20000; ++i) {
			if (i == 19999) {
				nx = -1;
				break;
			}
			if (field[ny][nx] == 4) {
				break;
			}
			else {
				nx += dx[field[ny][nx]];
				ny += dy[field[ny][nx]];
			}
		}
		if (nx == -1) {
			cout << "LOOP" << endl;
		}
		else {
			cout << nx << " " << ny << endl;
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int h, w;
	std::string buf;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	std::cin.rdbuf(ifs.rdbuf());
#endif

	while(std::cin >> h >> w){
		if(h == 0 && w == 0){ break; }
		std::vector<std::string> image;
		std::vector<std::vector<bool> >  is_visited(h, std::vector<bool>(w, false));
		int x = 0;
		int y = 0;

		for(int y = 0; y < h; y++){
			std::cin >> buf;
			image.push_back(buf);
		}

		while(true){
			if(image[y][x] == '.'){
				std::cout << x << " " << y << std::endl;
				break;
			}
			if(is_visited[y][x]){
				std::cout << "LOOP" << std::endl;
				break;
			}
			is_visited[y][x] = true;
			switch(image[y][x]){
			case '>':
				x++;
				break;
			case '<':
				x--;
				break;
			case '^':
				y--;
				break;
			case 'v':
				y++;
				break;
			default:
				break;
			}
		}
	}


#if INPUT_FROM_FILE
		//fclose(fp);
#endif
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#define rep(i,n) for(i=0;i<(n);++i)
int n, m, i, j, x, y, loop;
char buf[102];
char tile[102][102];
bool visited[102][102];

int main()
{
    while (true) {
        fgets(buf, 102, stdin);
        sscanf(buf, "%d %d", &n, &m);
        if (!(m|n)) break;

        rep(i, n) rep(j, m) visited[i][j] = false;
        rep(i, n) fgets(tile[i], 102, stdin);
        x = y = loop = 0;
        visited[y][x] = true;
        while (tile[y][x] != '.') {
            switch (tile[y][x]) {
                case '>': x++; break;
                case 'v': y++; break;
                case '<': x--; break;
                case '^': y--; break;
            }
            if (visited[y][x]) { loop = 1; break; }
            visited[y][x] = true;
        }
        if (loop) puts("LOOP"); else printf("%d %d\n", x, y);
    }
    return 0;
}

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

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

    bool p[N][N];
    char data[N][N];

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> data[i][j];
	p[i][j]=false;
      }
    }

    int x=0, y=0;
    flag=false;
    while(1){
      if(p[y][x]){
	flag=true;
	break;
      }
      p[y][x]=true;
      if(data[y][x]=='>'){
	x++;
      }
      else if(data[y][x]=='<'){
	x--;
      }
      else if(data[y][x]=='^'){
	y--;
      }
      else if(data[y][x]=='v'){
	y++;
      }
      else if(data[y][x]=='.'){
	break;
      }
    }
    if(flag) cout << "LOOP" << endl;
    else cout << x << ' ' << y << endl;
  }
  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;
	}
	
		return false;
	
}
int main(){
	char ma[100][100];

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

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

		}
	}
	return 0;
}

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

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

char t[]={'<','^','>','v'};

char f[101][101];
bool v[100][100];
int X,Y;

bool dfs()
{
	if(v[X][Y]) return false;
	v[X][Y]=1;
	if(f[X][Y]=='.') return true;
	
	for(int i=0; i<4; i++)
	{
		if(t[i]==f[X][Y]) 
		{
			X+=dx[i];
			Y+=dy[i];
		}
	}
	return dfs();
}

int main()
{
	int H,W;
	while(cin >> H >> W, (H||W))
	{
		for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
			cin >> f[j][i];
			
		X=0; Y=0;
		
		bool f=dfs();
		if(f) cout << X << " " << Y << endl;
		else cout << "LOOP" << endl;
		
	}
}