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 <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
typedef pair<int,int> P;
bool field[101][101]={};
char a[101][101];
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m) && n){
		for(int i=0;i<n;i++){
			scanf("%s",a[i]);
		}
		memset(field,0,sizeof(field));
		queue<P>que;
		que.push(make_pair(0,0));
		while(!que.empty()){
			P p=que.front();
			int x=p.first;
			int y=p.second;
			que.pop();
			if(field[x][y]){
				puts("LOOP");
			}else if(a[x][y]=='>'){
				que.push(make_pair(x,y+1));
			}else if(a[x][y]=='v'){
				que.push(make_pair(x+1,y));
			}else if(a[x][y]=='<'){
				que.push(make_pair(x,y-1));
			}else if(a[x][y]=='^'){
				que.push(make_pair(x-1,y));
			}else{
				printf("%d %d\n",y,x);
			}
			field[x][y]=true;
		}
	}
}

C++: #include <iostream>

int main(int argc, char **argv)
{
	int h, w;
	int x = 0, y = 0;
	char tiles[100][100];
	bool throughed[100][100] = {};
	bool loop = false;
	bool end = false;
	while(std::cin >> h >> w, h+w != 0){
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				std::cin >> tiles[j][i];
			}
		}
		while(true){
			if(throughed[x][y]){
				loop = true;
				break;
			}
			throughed[x][y] = true;
			switch(tiles[x][y]){
				case '.':
					end = true;
					break;
				case '^':
					y--;
					break;
				case 'v':
					y++;
					break;
				case '<':
					x--;
					break;
				case '>':
					x++;
					break;
			}
			if(end){
				break;
			}
		}
		if(loop){
			std::cout << "LOOP" << std::endl;
		}else{
			std::cout << x << " " << y << std::endl;
		}
	}
	return 0;
}

C++: // 2011/01/07 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int H, W;
		cin >> H >> W;
		if(H==0&&W==0)
			break;

		char til[101][101];
		for(int i=0; i<H; i++)
			for(int j=0; j<W; j++){
				char tmp;
				do{
					cin >> tmp;
				}while(tmp!='>'&&tmp!='<'&&tmp!='v'&&tmp!='^'&&tmp!='.');
				til[i][j] = tmp;
			}

		bool flg[101][101];
		for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
				flg[i][j] = false;

		int x = 0;
		int y = 0;
		while(true){
			if(flg[y][x]){
				cout << "LOOP" << endl;
				break;
			}

			flg[y][x] = true;

			if(til[y][x]=='>')
				x++;
			else if(til[y][x]=='<')
				x--;
			else if(til[y][x]=='v')
				y++;
			else if(til[y][x]=='^')
				y--;
			else{
				cout << x << ' ' << y << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;


int main()
{
	char* dir = "><^v";
	int dx[] = { 1, -1, 0, 0 };
	int dy[] = { 0, 0, -1, 1 };

	while (true)
	{
		int H, W;
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)
			break;

		char tile[128][128];
		for (int i = 0; i < H; ++i)
			scanf("%s", tile[i]);

		bool visit[128][128];
		for (int i = 0; i < H; ++i)
			for (int j = 0; j < W; ++j)
				visit[i][j] = false;

		int x, y;
		x = y = 0;
		while (true)
		{
			char c = tile[y][x];
			if (c == '.')
				break;
			else if(visit[y][x])
			{
				x = -1;
				break;
			}

			visit[y][x] = true;
			for (int i = 0; i < 4; ++i)
			{
				if (c == dir[i])
				{
					x += dx[i];
					y += dy[i];
					break;
				}
			}
		}
		if (x == -1)
			printf("LOOP\n");
		else
			printf("%d %d\n", x, y);
	}

	return 0;
}

C++: #include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

typedef struct {
	int x, y;
}Loc;

int H, W;
string tile[100];
bool al[100][100];
Loc l = { 0,0 };


bool check()
{
	if (al[l.x][l.y])
	{
		cout << "LOOP" << endl;
		return true;
	}
	else
	{
		al[l.x][l.y] = true;
		return false;
	}
}

int main()
{
	while (cin >> H >> W && H != 0)
	{
		l = { 0,0 };
		for (int i = 0; i < H; i++) {
			cin >> tile[i];
			for (int j = 0; j < W; j++)
				al[i][j] = false;
		}
		al[0][0] = true;
		while (true) {
			if (tile[l.x][l.y] == '<')
			{
				l.y--;
				if (check())
					break;
			}
			else if (tile[l.x][l.y] == '>')
			{
				l.y++;
				if (check())
					break;
			}
			else if (tile[l.x][l.y] == 'v')
			{
				l.x++;
				if (check())
					break;;
			}
			else if (tile[l.x][l.y] == '^')
			{
				l.x--;
				if (check())
					break;
			}
			else
			{
				cout << l.y << " " << l.x << endl;
				break;
			}
		}
	}
	return 0;
}

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

int main(){
	int w,h;
	while(cin>>w>>h &&w&&h)
	{
		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++: /*
	0104:Magical Tiles
*/
#include	<iostream>
#include	<vector>
#include	<cstdio>

using namespace std;

int main(void) {
	int H, W;
	while(1) {
		cin >> W >> H;
		if(H == 0 && W == 0) {
			break;
		}
		vector< vector<char> > tiles;
		vector< vector<int> > status;
		
		tiles.resize(W + 1);
		status.resize(W + 1);
		for(int i = 0; i < (int)tiles.size(); i++) {
			tiles[i].resize(H + 1);
			status[i].resize(H + 1);
		}
		
		for(int i = 0; i < (int)tiles.size() - 1; i++) {
			for(int j = 0; j < (int)tiles[i].size(); j++) {
				scanf("%c", &tiles[i][j]);
			}
		}
		
		for(int i = 0; i < (int)status.size(); i++) {
			for(int j = 0; j < (int)status[i].size(); i++) {
				status[i][j] = 0;
			}
		}
		
		int a = 0, b = 0;
		while(1) {
			if(tiles[a][b] == '.') {
				cout << b << ' ' << a << endl;
				break;
			}
			else if(status[a][b] == 1) {
				cout << "LOOP" << endl;
				break;
			}
			else {
				status[a][b] = 1;
				
				if(tiles[a][b] == '<') {
					//cout << "MOVE:" << '<' << endl;
					b--;
				}
				else if(tiles[a][b] == '>') {
					//cout << "MOVE:" << '>' << endl;
					b++;
				}
				else if(tiles[a][b] == '^') {
					//cout << "MOVE:" << '^' << endl;
					a--;
				}
				else if(tiles[a][b] == 'v') {
					//cout << "MOVE:" << 'v' << endl;
					a++;
				}
			}
		}
	}
	
	return 0;
}