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>
#include <algorithm>

using namespace std;

bool search(char a[101][101], bool vis[101][101], int s, int t)
{
	if(vis[s][t]){
		return true;
	}
	vis[s][t] = true;
	
	if(a[s][t] == '>'){
		return search(a, vis, s, t+1);
	}
	if(a[s][t] == '^'){
		return search(a, vis, s-1, t);
	}
	if(a[s][t] == '<'){
		return search(a, vis, s, t-1);
	}
	if(a[s][t] == 'v'){
		return search(a, vis, s+1, t);
	}
	
	cout << t << " " << s << endl;
	return false;
}

int main()
{
	int h, w;
	bool vis[101][101];
	char a[101][101];
	
	while(1){
		cin >> h >> w;
		if(h == 0 && w == 0){
			break;
		}
		fill(&vis[0][0], &vis[h][w], false);
		
		for(int i = 0; i < h; i++){
			cin >> a[i];
		}
		
		if(search(a, vis, 0, 0)){
			cout << "LOOP" << endl;
		}
	}
	
	return 0;
}

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

using namespace std;

int main(){
	int w, h;
	char room[101][101];
	vector< pair<int, int> > visited;
	while(cin >> h >> w, h || w){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> room[i][j];
			}
		}
		visited.push_back(pair<int, int>(0, 0));
		int flag = 1;
		while (flag){
			pair<int, int> tmp;
			switch (room[visited.back().first][visited.back().second])
			{
			case '>':
				tmp.first = visited.back().first;
				tmp.second = visited.back().second + 1;
				visited.push_back(tmp);
				break;
			case '<':
				tmp.first = visited.back().first;
				tmp.second = visited.back().second - 1;
				visited.push_back(tmp);
				break;
			case '^':
				tmp.first = visited.back().first - 1;
				tmp.second = visited.back().second;
				visited.push_back(tmp);
				break;
			case 'v':
				tmp.first = visited.back().first + 1;
				tmp.second = visited.back().second;
				visited.push_back(tmp);
				break;
			case '.':
				cout << visited.back().second << ' ' << visited.back().first << endl;
				flag = 0;
				visited.clear();
				break;
			}
			for (int i = visited.size() - 2; i >= 0; i--){
				if (visited[i] == tmp){
					cout << "LOOP" << endl;
					flag = 0;
					break;
				}
			}
		}
		visited.clear();
	}
	return 0;
}

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

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