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 w,h,x,y;
	char tile[100][100];
	bool use[100][100];
	bool flg;
	
	while(1){
	 cin>>w>>h;
	 for(y=0;y<h;y++){
	  for(x=0;x<w;x++){
	   cin>>tile[x][y];
	   use[x][y]=false;
	  }
	 }
	 
	 x=0;y=0;flg=false;
	 do{
	  if(use[x][y]){cout<<"LOOP"<<endl;break;}
	  use[x][y]=true;
	  switch(tile[x][y]){
		case '.':
		flg=true;
		cout<<x<<" "<<y;
		break;

		case '>':
		x+=1;
		break;

		case '<':
		x-=1;
		break;

		case '^':
		y-=1;
		break;

		case 'v':
		y+=1;
		break;
	  }
	 }while(flg);
	}
}

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[101][101];
		for(int y=0; y<H; y++)
			for(int x=0; x<W; x++)
				cin >> til[y][x];

		bool flg[101][101];
		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 <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

using namespace std;

#define all(c) c.begin(),c.end()
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& val){
    os << "[ ";
    for(typename vector<T>::const_iterator it=val.begin();
        it != val.end();++it){
        os << *it << " ";
    }
    os << "]";
    return os;
}
vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,-1,0,1};

inline int mc(char c){
// '>' (大なり記号): 東向きの矢印が書かれたタイル
// '<' (小なり記号): 西向きの矢印が書かれたタイル
// '^' (べき記号) : 北向きの矢印が書かれたタイル
// 'v' (小文字ブイ): 南向きの矢印が書かれたタイル
// '.' (ピリオド) : 何も書かれていないタイル
    switch(c){
    case '>':
        return 0;
    case '<':
        return 2;
    case '^':
        return 1;
    case 'v':
        return 3;
    case '.':
        return -1;
    }
    return -1;
}

string solve(vector<string> field){

    int W = field[0].size();
    int H = field.size();
    vector<vector<char> > alr(H,vector<char>(W,false));

    int nx = 0;
    int ny = 0;
    while(mc(field[ny][nx]) != -1){
        if(alr[ny][nx]){
            return "LOOP";
        }
        alr[ny][nx] = true;
        int d = mc(field[ny][nx]);
        ny += dy[d];
        nx += dx[d];
    }
    stringstream ss;
    ss << nx << " " << ny;
    return ss.str();
}
int main(){
    while(true){
        int W,H;
        cin >> H >> W;
        if(W == 0 and H == 0) break;
        vector<string> field(H);
        for(int i=0;i<H;i++){
            cin >> field[i];
        }
        cout << solve(field) << endl;
    }
    return 0;
}

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

C++: #include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int loop_counter[100][100]={0};
string board[100];
int loop(int y,int x){

	if(loop_counter[y][x]){
		cout<<"LOOP"<<endl;
		return 0;
	}
	loop_counter[y][x]=1;
	if(board[y][x]=='^'){
		return loop(y-1,x);
	}
	else if(board[y][x]=='v'){
		return loop(y+1,x);
	}
	else if(board[y][x]=='<'){
		return loop(y,x-1);
	}
	else if(board[y][x]=='>'){
		return loop(y,x+1);
	}
	else if(board[y][x]=='.'){
		cout << x <<" "<<y<<endl;
		return 0;
	}
	return 0;
}
int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h==0 && w==0)
			return 0;
		for(int i=0 ; i<h ; i++ )
			cin >> board[i];
		loop(0,0);
	}
}

C++: #include<stdio.h>
int a,b,limx,limy;
char s[102][102];
int pass[102][102];
void check(int x,int y){
    if(pass[x][y]!=1){
        a=x,b=y;
        pass[x][y]=1;
        if(s[x][y]=='^'&&x-1>=0)
        check(x-1,y);
        if(s[x][y]=='v'&&x+1<=limx)
        check(x+1,y);
        if(s[x][y]=='>'&&y+1<=limy)
        check(x,y+1);
        if(s[x][y]=='<'&&y-1>=0)
        check(x,y-1);
    }
    else
    a=-1;
}
main(){
    int x,y,i,j;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)
        break;
        limx=x;limy=y;
        for(i=0;i<x;i++)
        for(j=0;j<y;j++)
        pass[x][y]=0;
        for(i=0;i<x;i++)
        scanf("%s",&s[i]);
        check(0,0);
        if(a!=-1)
        printf("%d %d\n",b,a);
        else
        printf("LOOP\n");
    }
}

C++: 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){
		x = 0;
		y = 0;
		for(int i = 0; i < 100; i++){
			for(int j = 0; j < 100; j++){
				throughed[j][i] = false;
			}
		}
		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;
}