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

using namespace std;

int main(){
	char t[100][100];
	char temp;
	int H,W,i,j,loopch;
	
	while(scanf("%d %d",&H,&W)){
		if(H==0&&W==0)
		break;
		string s;
		cin.ignore();
		for(i=0;i<H;i++){
			getline(cin,s);
			for(j=0;j<W;j++){
				t[i][j] = s[j];
			}
		}
		i=0;
		j=0;
		loopch=0;
		while(t[i][j]!='.'){
			if(t[i][j]=='>'){
				t[i][j]='*';
				j++;
			}
			else if(t[i][j]=='<'){
				t[i][j]='*';
				j--;
			}
			else if(t[i][j]=='^'){
				t[i][j]='*';
				i--;
			}
			else if(t[i][j]=='v'){
				t[i][j]='*';
				i++;
			}
			else if(t[i][j]=='*'){
				loopch=1;
				break;
			}
		}
		if(loopch!=1)
		printf("%d %d\n",j,i);
		else
		printf("LOOP\n");
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  while(cin>>H>>W,H+W!=0){
    string tile[H];
    for(int i=0;i<H;i++)
      cin>>tile[i];
    if(tile[0][0]=='.'){
      cout<<"0 0"<<endl;
      continue;
    }
    int i=0;
    pair<int,int> now=make_pair(0,0);
    while(i!=20001){
      i++;
      if(i==20000)
	cout<<"LOOP"<<endl;
      if(tile[now.first][now.second]=='.'){
	cout<<now.second<<" "<<now.first<<endl;
	break;
      }else if(tile[now.first][now.second]=='>')
	now.second++;
      else if(tile[now.first][now.second]=='<')
	now.second--;
      else if(tile[now.first][now.second]=='v')
	now.first++;
      else if(tile[now.first][now.second]=='^')
	now.first--;
    }
  }
  return 0;
}

C++: #include<iostream>

void move(int, int);

char tiles[101][101];
bool mem[101][101];

int main()
{
  int H, W;
  while(true)
  {
    std::cin >> H >> W;
    if(!H && !W)
      break;

    for(int i = 0; i < H; i++)
      std::cin >> tiles[i];
    
    move(0, 0);
  }
}

void move(int x, int y)
{
  if(mem[y][x])
  {
    std::cout << "LOOP" << std::endl;
    return;
  }

  mem[y][x] = true;

  switch(tiles[y][x])
  {
    case '<':
      move(x - 1, y);
      return;
    case '>':
      move(x + 1, y);
      return;
    case '^':
      move(x, y - 1);
      return;
    case 'v':
      move(x, y + 1);
      return;
    case '.':
      std::cout << x << " " << y << std::endl;
      return;
  }
}

C++: #include<stdio.h>

int main(){

char x[102]={};
char n[102][102]={};

int w,h;

while(1){

scanf("%d %d",&h,&w);
if(h==0&&w==0)break;
bool f[102][102]={};
for(int i=0;i<h;i++)
{scanf("%s",&x);
for(int j=0;j<=w;j++)
{	n[i][j]=x[j];f[i][j]=true;}
}


int a=0,b=0;
while(f[b][a]!=false){
if(n[b][a]=='>'){a++;f[b][a-1]=false;}
else if(n[b][a]=='<'){a--;f[b][a+1]=false;}
else if(n[b][a]=='v'){b++;f[b-1][a]=false;}
else if(n[b][a]=='^'){b--;f[b+1][a]=false;}
else if(n[b][a]=='.'){break;}
}

if(f[b][a]==false)printf("LOOP\n");
else printf("%d %d\n",a,b);
}
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    int H, W; cin >> H >> W;
    do {
        char state[H][W];
        bool used[H][W] = {true};
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> state[i][j];
                used[i][j] = true;
            }
        }

        int i = 0, j = 0;
        while (state[i][j] != '.' && used[i][j] == true) {
            used[i][j] = false;
            if (state[i][j] == '>') j++;
            else if (state[i][j] == '<') j--;
            else if (state[i][j] == '^') i--;
            else i++;

        }
        if (used[i][j] == false) cout << "LOOP" << endl;
        else cout << j << " " << i << endl;
        cin >> H >> W;
    } while (H != 0 && W != 0);
    return 0;

}

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

char map[11][11] ;
char d[] = { '>' , 'v' , '<' , '^' } ;
int dx[] = { 1,0,-1,0 } ;
int dy[] = { 0,1,0,-1 } ;

void move( int y , int x ){
	if( map[y][x] == '.' ) cout << x << ' ' << y << endl ;
	else if( map[y][x] == '0' ) cout << "LOOP" << endl ;
	else {
		for( int j=0 ; j<4 ; j++ ){
			if( map[y][x] == d[j] ){
				map[y][x] = '0' ;
				move( y+dy[j] , x+dx[j] ) ;
			}
		}
	}
}

int main(){
	
	int h , w ;
	
	while( cin >> h >> w , h ){
		for( int i=0 ; i<h ; i++ ){
			for( int j=0 ; j<w ; j++ ){
				cin >> map[i][j] ;
			}
		}
		
		move(0,0) ;
	}
	
return 0 ;
}

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

int w, h;
char map[102][102];
bool closed[102][102];
void rec(int x, int y){
  if(closed[y][x]){
    cout << "LOOP" << endl;
    return;
  }
  closed[y][x] = true;
  if(map[y][x] == '>')rec(x+1,y);
  else if(map[y][x] == 'v')rec(x, y+1);
  else if(map[y][x] == '<')rec(x-1,y);
  else if(map[y][x] == '^')rec(x,y-1);
  else {
    cout << x << " " << y << endl;
  }
}
void solve(){
  rec(0,0);
}
int main(){
  while(cin >> h >> w, w||h){
    memset(closed, 0, sizeof(closed));
    for(int i = 0; i < h; i++)cin >> map[i];
    solve();
  }
  return 0;
}

C++: 
#include <iostream>
#include <istream>
#include <ostream>

class Tiles {
	char **dir;
	bool **visited;
	int pos_x, pos_y;
	int h, w;
public:
	Tiles(std::istream& is) {
		is >> h >> w;
		if (h == 0 && w == 0) {
			return;
		}
		dir = new char*[h];
		visited = new bool*[h];
		for (int i = 0; i < w; i++) {
			dir[i] = new char[w];
			visited[i] = new bool[w];
		}
		pos_x = pos_y = 0;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				std::cin >> dir[i][j];
			}
		}
	}

	void solve() {
		if (visited[pos_y][pos_x]) {
			std::cout << "LOOP" << std::endl;
			return;
		}
		if (dir[pos_y][pos_x] == '.') {
			std::cout << pos_x << ' ' << pos_y << std::endl;
		} else {
			visited[pos_y][pos_x] = true;
			switch (dir[pos_y][pos_x]) {
			case '>':
				pos_x++;
				break;
			case '<':
				pos_x--;
				break;
			case 'v':
				pos_y++;
				break;
			case '^':
				pos_y--;
				break;
			}
			solve();
		}
	}

	bool is_empty() { return (h == 0 && w == 0); }
};

int main()
{
	Tiles *t;
	while (true) {
		t = new Tiles(std::cin);
		if (t->is_empty())
			break;
		t->solve();
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int h,w;
char c[110][110];
bool visited[110][110];
void dfs(int x,int y){
	if(visited[y][x]){
		cout<<"LOOP"<<endl;
		return;
	}
	visited[y][x]=true;
	if(c[y][x]=='>'){
		dfs(x+1,y);
		return;
	}
	if(c[y][x]=='<'){
		dfs(x-1,y);
		return;
	}
	if(c[y][x]=='v'){
		dfs(x,y+1);
		return;
	}
	if(c[y][x]=='^'){
		dfs(x,y-1);
		return;
	}
	cout<<x<<" "<<y<<endl;
	return;
}
int main(){
   	while(cin>>h>>w,h+w){
		for(int i=0;i<h;i++){
			cin>>c[i];
			for(int j=0;j<w;j++){
				visited[i][j]=false;
			}
		}
		dfs(0,0);
	}
    return 0;
}