Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	// var w, h int
	for scanner.Scan() {
		// fmt.Scanf("%d %d", &w, &h)

		input := strings.Split(scanner.Text(), " ")
		w, _ := strconv.Atoi(input[0])
		h, _ := strconv.Atoi(input[1])

		if w == 0 && h == 0 {
			return
		}

		isArrive := make([][]bool, w)
		tiles := make([][]string, w)

		for i := 0; i < w; i++ {
			rowArrive := make([]bool, h)
			rowTiles := make([]string, h)
			scanner.Scan()
			row := scanner.Text()
			for j := 0; j < h; j++ {
				rowTiles[j] = string(row[j])
			}
			tiles[i] = rowTiles
			isArrive[i] = rowArrive
		}

		var i, j int
		isEnd := false
		for {
			if isArrive[i][j] == true {
				fmt.Println("LOOP")
				break
			}
			isArrive[i][j] = true

			switch tiles[i][j] {
			case ">":
				j++
			case "^":
				i--
			case "v":
				i++
			case "<":
				j--
			case ".":
				isEnd = true
			}

			if isEnd == true {
				fmt.Println(j, i)
				break
			}
		}
	}
}

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

int main(){
	while(1){
		int h, w;
		char f[102][102];
		
		scanf(" %d %d", &h, &w);
		if(h==0) break;
		
		for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j)
		scanf(" %c", &f[i][j]);
		
		int x=0, y=0;
		bool loop=false;
		while(!loop && f[y][x]!='.'){
			//printf("%c\n", f[y][x]);
			if(f[y][x]=='a') loop=true;
			else{
				int tx=x, ty=y;
				
				if(f[y][x]=='>') ++x;
				else if(f[y][x]=='<') --x;
				else if(f[y][x]=='^') --y;
				else if(f[y][x]=='v') ++y;			
				
				f[ty][tx]='a';
			}
			
			//printf("%d %d\n", x, y);
		}
		
		if(loop) printf("LOOP\n");
		else printf("%d %d\n", x, y);
	}
}

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