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>
#include<cstring>
using namespace std;
char a[10000][10000]; int h, w, loop, cx, cy;
int main() {
	while (true) {
		cin >> h >> w;
		if (!h) { break; }
		memset(a, ' ', sizeof(a));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> a[i][j];
			}
		}
		cx = 0; cy = 0; loop = 0;
		while (true) {
			if (loop > 10000000) { cout << "LOOP" << endl; break; }
			if (a[cy][cx] == '.') { cout << cx << ' ' << cy << endl; break; }
			if (a[cy][cx] == '<') { cx--; }
			if (a[cy][cx] == '>') { cx++; }
			if (a[cy][cx] == '^') { cy--; }
			if (a[cy][cx] == 'v') { cx++; }
			loop++;
		}
	}
}

C++: #include<iostream>
using namespace std;
#define UUI long long int
UUI x,y,n,m;
char tile[120][120],a;
int main(){
    while(1){
            cin >> n >> m;
            if(n==0&&m==0)break;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a;
            tile[i][j]=a;
        }
    }
    x=0;
    y=0;
    while(1){
            if(tile[y][x]==0){
                    cout << "LOOP" << endl;
                    break;
            }
    if(tile[y][x]=='>'){
        tile[y][x]=0;
        x=x+1;
    }else if(tile[y][x]=='<'){
        tile[y][x]=0;
        x=x-1;
    }else if(tile[y][x]=='^'){
        tile[y][x]=0;
        y=y-1;
    }else if(tile[y][x]=='v'){
        tile[y][x]=0;
        y=y+1;
    }else if(tile[y][x]=='.'){
            cout << x <<" "<< y << endl;
        break;
    }
    }
    }
return 0;
}

C++: #include <iostream>

using namespace std;

char field[108][108];

int main() {
	while(true){
start:
		int h, w; cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				cin >> field[i][j];
			}
		}

		int x = 0, y = 0, c = 0;
		while (true){
			switch (field[y][x]){
			case '>':
				++x;
				break;
			case '<':
				--x;
				break;
			case '^':
				--y;
				break;
			case 'v':
				++y;
				break;
			default:
				printf("%d %d\n", x, y);
				goto start;
				break;
			}
			++c;
			if (c > w*h) {
				cout << "LOOP" << endl;
				goto start;
			}
		}
	}

	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;
			}
			int a = field[ny][nx];
			if (a == 4) {
				break;
			}
			else {
				nx += dx[a];
				ny += dy[a];
			}
		}
		if (nx == -1) {
			cout << "LOOP" << endl;
		}
		else {
			cout << nx << " " << ny << endl;
		}
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

char field[101][101];
bool isLeave[101][101];

char getNextPosTileAndNextPos(int x, int y, int* nextX, int* nextY)
{
	char result = '.';

	switch( field[y][x] )
	{
		case '>':
			result = field[y][x + 1];
			*nextX = x + 1;
			*nextY = y;
			break;
		case '<':
			result = field[y][x - 1];
			*nextX = x - 1;
			*nextY = y;
			break;
		case '^':
			result = field[y - 1][x];
			*nextX = x;
			*nextY = y - 1;
			break;
		case 'v':
			result = field[y + 1][x];
			*nextX = x;
			*nextY = y + 1;
			break;
		case '.':
			break;
	}
	return result;
}

int main()
{
	int w;
	int h;
	int x;
	int y;

	while( true )
	{
		scanf("%d%d", &h, &w);
		if( w == 0 && h == 0 )break;
		x = 0;
		y = 0;
		loop(i, 0, h)
		{
			scanf("%s", field[i]);
		}
		loop(i, 0, h)
		{
			loop(j, 0, w)
			{
				isLeave[i][j] = false;
			}
		}
		
		do
		{
			if( isLeave[y][x] )
			{
				printf("LOOP\n");
				break;
			}
			isLeave[y][x] = true;
		}
		while( getNextPosTileAndNextPos( x, y, &x, &y ) != '.' );
		if( field[y][x] == '.' )
		{
			printf("%d %d\n", x, y);
		}
	}
	return (0);
}

C++: #include <iostream>
#include <istream>
#include <ostream>
#include <cstdlib>

class Tiles {
	char **dir;
	bool **visited;
	int pos_x, pos_y;
public:
	Tiles(std::istream& is) {
		int h, w;
		is >> h >> w;
		if (h == 0 && w == 0) {
			exit(0);
		}
		dir = new char*[h];
		visited = new bool*[h];
		for (int i = 0; i < w; i++) {
			dir[i] = new char[w];
			visited[i] = new bool[w];
		}
		pos_x = pos_y = 0;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				std::cin >> dir[i][j];
			}
		}
	}

	void solve() {
		if (visited[pos_y][pos_x]) {
			std::cout << "LOOP" << std::endl;
			return;
		}
		if (dir[pos_y][pos_x] == '.') {
			std::cout << pos_x << ' ' << pos_y << std::endl;
		} else {
			visited[pos_y][pos_x] = true;
			switch (dir[pos_y][pos_x]) {
			case '>':
				pos_x++;
				break;
			case '<':
				pos_x--;
				break;
			case 'v':
				pos_y++;
				break;
			case '^':
				pos_y--;
				break;
			}
			solve();
		}
	}
};

int main()
{
	Tiles *t;
	while (true) {
		t = new Tiles(std::cin);
		t->solve();
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int H,W,x,y;
  while(cin>>H>>W){
    if(H==0&&W==0) break;
    char space[H][W],c;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> space[j][i];
      }
    }
    x = y = 0;
    while(1){
      c = space[x][y];
      space[x][y] = '0';
      if(c=='>') x++;
      else if(c=='<') x--;
      else if(c=='v') y++;
      else if(c=='^') y--;
      else if(c=='.'){
	cout << x << ' ' << y << endl;
	break;
      }
      else if(c=='0'){
	cout << "LOOP" << endl;
	break;
      }
    }
  }
  return 0;
}

C++: #include <stdio.h>
#include <string.h>
#define W_MAX 100
#define H_MAX 100
char map[H_MAX+1][W_MAX+1];
char gx,gy;
int solve(int posX,int posY)
{
	if(map[posY][posX]=='x')
		return 0;
	char c=map[posY][posX];
	map[posY][posX]='x';
	if(c=='^')
		return solve(posX,posY-1);
	else if(c=='v')
		return solve(posX,posY+1);
	else if(c=='>')
		return solve(posX+1,posY);
	else if(c=='<')
		return solve(posX-1,posY);
	else if(c=='.'){
		gx=posX;gy=posY;
		return 1;
	}
	return 1;
}
int main(void)
{
	int w,h,k;
	char str[101];
	while(true){
		scanf("%d%d",&h,&w);
		if(h==0||w==0)break;
		for(k=0;k<h;k++)
		{
			scanf("%s",&str);
			strcpy(map[k],str);
		}
		if(solve(0,0)==1)printf("%d %d\n",gx,gy);
		else printf("LOOP\n");
	}
}