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>
using namespace std;

int main(){
   int a, b, i, j;
   char map[102][102];
   
   while(1){
      cin >> a >> b;
      if(a+b==0) break;
      
      for(i=0; i< a; i++){
         for(j=0; j< b; j++){
            cin >> map[i][j];
         }
      }
      i=0;j=0;
      while(1){
         if(map[i][j]=='.'){
            cout << i << " " << j << endl;
            break;
         }else if(map[i][j]=='#'){
            cout << "loop" << endl;
            break;
         }else if(map[i][j]=='>'){
            map[i][j]='#';
            j++;
         }else if(map[i][j]=='<'){
            map[i][j]='#';
            j--;
         }else if(map[i][j]=='^'){
            map[i][j]='#';
            i++;
         }else if(map[i][j]=='v'){
            map[i][j]='#';
            i--;
         }
      }
   }
   return 0;
}

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

#include <iostream>
using namespace std;

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

		char til[100][100];
		for(int y=0; y<H; y++)
			for(int x=0; x<W; x++)
				cin >> til[y][x];

		bool flg[100][100];
		for(int y=0; y<H; y++)
			for(int x=0; x<W; x++)
				flg[y][x] = false;

		for(int x=0, y=0; ; ){
			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 if(til[y][x]=='.'){
				cout << x << ' ' << y << endl;
				break;
			}
		}
	}

	return 0;
}

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

int m,n,w,h;
char b[102][102];
bool v[102][102];

void dfs(int y,int x){
    if(v[y][x]){
        cout<<"LOOP"<<endl;
        return;
    }
    v[y][x]=1;
    if(b[y][x]=='>')
        dfs(y,x+1);
    if(b[y][x]=='v')
        dfs(y+1,x);
    if(b[y][x]=='<')
        dfs(y,x-1);
    if(b[y][x]=='^')
        dfs(y-1,x);
    cout<<x<<" "<<y<<endl;
}

int main(){
    while(cin>>h>>w,w||h){
        for(int i=0;i<h;i++)
            cin>>b[i];
        memset(v,0,sizeof(v));
        dfs(0,0);
    }
}

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

struct zahyou{
	int x;
	int y;
};

int main(){
	
	int tx,ty,count;
	char map[100][100];
	bool flag;
	struct zahyou now;
	
	
	
	while(cin>>tx>>ty,tx&&ty){
		
		flag=false;
		now.x=0;
		now.y=0;
		memset(map,'\0',sizeof(map));
		
		for(int i=0;i<ty;i++){
			for(int j=0;j<tx;j++){
				cin>>map[i][j];
			}
		}
		
		while(1){
			if(map[now.y][now.x]=='>'){
				map[now.y][now.x]=='\0';
				now.x++;
			}
			else if(map[now.y][now.x]=='<'){
				map[now.y][now.x]=='\0';
				now.x--;
			}
			else if(map[now.y][now.x]=='v'){
				map[now.y][now.x]=='\0';
				now.y++;
			}
			else if(map[now.y][now.x]=='^'){
				map[now.y][now.x]=='\0';
				now.y--;
			}
			
			if(map[now.y][now.x]=='.'){
				cout<<now.x<<" "<<now.y<<endl;
				break;
			}
			else if(map[now.y][now.x]=='\0'){
				cout<<"LOOP"<<endl;
				break;
			}
		}
	}
}

C++: #include<cstdio>
#include<algorithm>
#include<functional>
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
	int i,j,k,h,w,cnt;
	char mp[101][101];
	while(1) {
		cin>>h>>w;
		if(h==0&&w==0)break;
		for(i=0;i<h;i++) 
			for(j=0;j<w;j++) cin>>mp[i][j];
		cnt=0;
		i=0,j=0;
		while(1) {
			if('>'==mp[i][j]) j++,cnt++;
			if('v'==mp[i][j]) i++,cnt++;
			if('^'==mp[i][j]) i--;cnt++;
			if('<'==mp[i][j]) j--,cnt++;
			if('.'==mp[i][j]) {
				cout<<j<<" "<<i<<endl;
				break;
			}
			if(cnt>10000) {
				cout<<"LOOP"<<endl;
				break;
			}
		}
	}
}

C++: #include<stdio.h>
int main(void)
{
	int h,w;
	int i,j;
	char map[101][101];
	int flg[101][101];
	
	scanf("%d %d",&h,&w);
	while(h!=0 && w!=0){
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				flg[i][j]=0;
			}
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				scanf(" %c",&map[i][j]);
			}
		}
		i=0;
		j=0;
		while(1){
			if(map[i][j]=='.' || flg[i][j]==1){
				break;
			}
			else if(map[i][j]=='>'){
				flg[i][j]=1;
				j++;
			}
			else if(map[i][j]=='<'){
				flg[i][j]=1;
				j--;
			}
			else if(map[i][j]=='^'){
				flg[i][j]=1;
				i--;
			}
			else if(map[i][j]=='v'){
				flg[i][j]=1;
				i++;
			}
		}
		if(flg[i][j]==1){
			printf("LOOP\n");
		}
		else {
			printf("%d %d\n",j,i);
		}
		scanf("%d %d",&h,&w);
	}
	return 0;
}

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

using namespace std;

int H, W;
vector<string> tiles;
bool reached[110][110];

int main() {
	while (1) {
		cin >> H >> W; if (H == 0 && W == 0) break;
		
		tiles.assign(H, "");
		for (int i = 0; i < H; i++) {
			cin >> tiles[i];
		}
		
		memset(reached, 0, sizeof(reached));
		
		int x = 0, y = 0;
		bool loop = false;
		while (tiles[y][x] != '.') {
			if (reached[y][x]) {
				loop = true;
				break;
			}
			reached[y][x] = true;
			char t = tiles[y][x];
			
			if (t == '>') {
				x++;
			}
			if (t == '<') {
				x--;
			}
			if (t == '^') {
				y--;
			}
			if (t == 'v') {
				y++;
			}
		}
		
		if (loop) cout << "LOOP" << endl;
		else cout << x << " " << y << endl;
	}
	
	return 0;
}

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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int W, H;
	while(cin >> H >> W, W, H)
	{
		bool Flag[128][128];
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				Flag[i][j] = false;
			}
		}
		vector< vector<char> > Field(H);
		for(int i = 0; i < H; ++i)
		{
			Field[i].resize(W);
		}
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				cin >> Field[i][j];
			}
		}
		P Pos(0, 0);
		bool LoopFlag = false;
		while(true)
		{
			if(Flag[Pos.second][Pos.first] == true)
			{
				LoopFlag = true;
				break;
			}
			Flag[Pos.second][Pos.first] = true;
			if(Field[Pos.second][Pos.first] == '>')
			{
				++Pos.first;
			}
			else if(Field[Pos.second][Pos.first] == '<')
			{
				--Pos.first;
			}
			else if(Field[Pos.second][Pos.first] == '^')
			{
				--Pos.second;
			}
			else if(Field[Pos.second][Pos.first] == 'v')
			{
				++Pos.second;
			}
			else if(Field[Pos.second][Pos.first] == '.')
			{
				break;
			}
		}
		if(!LoopFlag)
		{
			cout << Pos.first << " " << Pos.second << endl;
		}
		else
		{
			cout << "LOOP" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<stdio.h>
char c[100][100];
int main(){
	int a;
	int b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)
			for(int j=0;j<b;j++)
				scanf(" %c",&c[i][j]);
		
		int s=0;
		int t=0;
		while(1){
			switch(c[s][t]){
				case '>':
					c[s][t]='x';
					t++;
					break;
				case '<':
					c[s][t]='x';
					t--;
					break;
				case 'v':
					c[s][t]='x';
					s++;
					break;
				case '^':
					c[s][t]='x';
					s--;
					break;
			}
			if(c[s][t]=='x')break;
			if(c[s][t]=='.')break;
		}
		if(c[s][t]=='x')printf("LOOP\n");
		else printf("%d %d\n",t,s);
	}
}