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 <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int h,w;
char cell[110][110];
bool used[110][110];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(cin >> h >> w){
		if(h == 0 && w == 0) break;
		rep(i,110) rep(j,110) used[i][j] = 0;
		rep(i,h) rep(j,w) cin >> cell[i][j];
		P p; p.fi = 0; p.sec = 0;
		while(true){
			if(used[p.fi][p.sec]){
				cout << "LOOP" << endl;
				break;
			}
			used[p.fi][p.sec] = 1;
			if(cell[p.fi][p.sec] == '.'){
				cout << p.sec << " " << p.fi << endl;
				break;
			}
			else if(cell[p.fi][p.sec] == '^') p.fi--;
			else if(cell[p.fi][p.sec] == '<') p.sec--;
			else if(cell[p.fi][p.sec] == '>') p.sec++;
			else if(cell[p.fi][p.sec] == 'v') p.fi++;
		}
	}
}

C++: //Magical Tiles
#include <iostream>

using namespace std;

int main(){
	int H, W;
	char Tile[101][101];//縦横 HW
	bool TileIsMoved[101][101];
	bool IsLoop,IsEnd;
	char Loader[101];//横行読み
	int px, py;//人位置
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		//初期化
		px = 0; py = 0;
		IsLoop = false;
		IsEnd = false;
		//タイル代入/moved初期化
		for (int i = 0; i < H; ++i){
			cin >> Loader;
			for (int j = 0; j < W; ++j){
				Tile[i][j] = Loader[j];
				TileIsMoved[i][j] = false;
			}
		}
		TileIsMoved[0][0] = true;
		//移動
		while (1){
			switch (Tile[px][py]){
			case '>':
				++px;
				break;
			case '^':
				--py;
				break;
			case 'v':
				++py;
				break;
			case '<':
				--px;
				break;
			case '.':
				IsEnd = true;
				break;
			}
			if (IsEnd)break;
			if (TileIsMoved[px][py]){
				IsLoop = true;
				break;
			}
			TileIsMoved[px][py] = true;
		}
		//出力
		if (IsLoop){
			cout << "LOOP" << endl;
		} else{
			cout << px << " " << py << endl;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		int co=0;
		int x=0,y=0;
		while(co!=1e6){
			co++;
			if(in[x][y]=='>')y++;
			else if(in[x][y]=='<')y--;
			else if(in[x][y]=='^')x--;
			else if(in[x][y]=='v')x++;
			else break;
		}
		if(co==1e6)cout<<"LOOP"<<endl;
		else cout<<y<<" "<<x<<endl;
	}
}

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

int x, y, d, HW, H, W;
string input[10];
bool orLoop[10][10];

int loop(int a, int b){
	if(orLoop[b][a]){
		return true;
	}
	char i = input[b][a];
	if(i=='>'){
		orLoop[b][a] = true;
		loop(a + 1, b);
	}
	else if(i=='v'){
		orLoop[b][a] = true;
		loop(a, b + 1);
	}
	else if(i=='<'){
		orLoop[b][a] = true;
		loop(a - 1, b);
	}
	else if(i=='^'){
		orLoop[b][a] = true;
		loop(a, b - 1);
	}
	else{
		x = a;
		y = b;
		return false;
	}
}

int main(){
	while(cin >> H >> W){
		if (H == 0 && W == 0) { break; }
		else { HW = H*W + 2; }

		for (int i = 0; i < 10;i++){
			for (int j = 0; j < 10;j++){
				orLoop[i][j] = false;
			}
		}
			for (int i = 0; i < H; i++)
			{
				cin >> input[i];
			}
		if(loop(0, 0)){
			cout << "LOOP" << endl;
		}
		else{
			cout << x << " " << y << endl;
		}
	}
	return 0;
}

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

int h,w;
char b[100][101];
bool visit[100][100];

int main(){
	while(cin>>h>>w,h|w){
		cin.ignore();
		for(int i=0;i<h;i++)cin>>b[i];
		int y=0,x=0;
		memset(visit,false,sizeof(visit));
		while(!visit[y][x]&&b[y][x]!='.'){
			visit[y][x]=true;
			if(b[y][x]=='>')x++;
			else if(b[y][x]=='<')x--;
			else if(b[y][x]=='^')y--;
			else if(b[y][x]=='v')y++;
		}
		if(visit[y][x])cout<<"LOOP"<<endl;
		else cout<<x<<' '<<y<<endl;
	}
	return 0;
}

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

#define MAX 100

int main(void)
{
  int H, W;
  char tile[MAX][MAX];

  while (1) {
    
    int x = 0, y = 0;

    for(int i = 0 ; i < MAX ; i++) {
      for(int j = 0 ; j < MAX ; j++) {
	tile[i][j] = '.';
      }
    }
    
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    
    for(int i = 0 ; i < H ; i++) {
      for(int j = 0 ; j < W ; j++) {
	cin >> tile[i][j];
      }
    }
    
    int cal=0, sum=0;
    cal = H * W;

    //for(int i = 0 ; i < H ; i++) {
    //for(int j = 0 ; j < W ; j++) {
    while(tile[x][y] != '.') {
      if(tile[x][y] == '>') y++, sum++; 
      else if(tile[x][y] == '<') y--, sum++;
      else if(tile[x][y] == '^') x--, sum++;
      else if(tile[x][y] == 'v') x++, sum++;
      if(sum > cal) break;
      //cout << "x = " << x << endl << "y = " << y << endl;
    }
    if(sum <= cal) cout << y << ' ' << x << endl;
    else cout << "LOOP" << endl;
  }
  return 0;
}

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