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<iostream>

using namespace std;

char map[110][110];
int s_x,s_y,loop;

void serch(int x,int y)
{
	if(map[x][y]=='1')
	{
		loop=1;
		return ;
	}
	if(map[x][y]=='.')
	{
		s_x=x;
		s_y=y;
		return ;
	}
	if(map[x][y]=='>')
	{
//		cout << "x:" << x << " y:" << y <<" nowmap:" << map[x][y] << endl;
		map[x][y]='1';
		serch(x,y+1);
	}
	else if(map[x][y]=='<')
	{
//		cout << "x:" << x << " y:" << y <<" nowmap:" << map[x][y] << endl;
		map[x][y]='1';
		serch(x,y-1);
	}
	else if(map[x][y]=='v')
	{
//		cout << "x:" << x << " y:" << y <<" nowmap:" << map[x][y] << endl;
		map[x][y]='1';
		serch(x+1,y);
	}
	else if(map[x][y]=='^')
	{
//		cout << "x:" << x << " y:" << y <<" nowmap:" << map[x][y] << endl;
		map[x][y]='1';
		serch(x-1,y);
	}
	return ;
}

int main()
{
	int w,h;
	int i,j;
	
	for(;;)
	{
		loop=0;
		cin >> w >> h ;
		if(w==0 && h==0)
			break;
		for(i=0;i<w;i++)
		{
			for(j=0;j<h;j++)
			{
				cin >> map[i][j] ;
			}
		}
		
		serch(0,0);
		
		if(loop==1)
			cout << "LOOP" << endl;
		else
			cout << s_y << " " << s_x << endl;
	}
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int h, w;
	while (cin >> h >> w && (h || w)) {
		VS tile(h); vector<VB> visited(h, VB(w));
		rep(i, h)cin >> tile[i];

		PII now = mp(0, 0), ans = mp(-1, -1); bool loop = false;
		while (!loop && ans.first == -1 && ans.second == -1) {

			if (visited[now.second][now.first])loop = true;
			visited[now.second][now.first] = true;

			switch (tile[now.second][now.first]) {
			case '.':
				ans = now;
				break;
			case '>':
				now.first++;
				break;
			case '<':
				now.first--;
				break;
			case '^':
				now.second--;
				break;
			case 'v':
				now.second++;
				break;
			}

		}

		if (loop)puts("LOOP");
		else Cout2(ans.first, ans.second);
	}
}

C++: #include <iostream>
#include <string>
#include <cstdio>
#define MAX_N 105

using namespace std;
int n,h,w;
int area[MAX_N][MAX_N];;
string s[MAX_N];

void move(int h,int w){
	if(area[h][w]==1){
		cout << "LOOP" << endl;
		return;
	}
	area[h][w]=1;
	
	switch(s[h][w]){
		case'>':
		move(h,w+1);
		return;
		break;
		case'<':
		move(h,w-1);
		return;
		break;
		case'v':
		move(h+1,w);
		return;
		break;
		case'^':
		move(h-1,w);
		return;
		break;
		case'.':
		cout << w<< " "<<h<<endl;
		return;
		break;
	}
}

int main(){
	while(1){
		cin >> h >> w;
		if(h==0&&w==0)break;
		for(int i=0;i<h;i++){
			cin >> s[i];
		}
		move(0,0);

	}
	return 0;
}

C++: //51
#include<iostream>

using namespace std;

int main(){
  for(int W,H;cin>>W>>H,W|H;){
    char g[100][100];
    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
	cin>>g[y][x];
      }
    }
    int y=0,x=0;
    while(g[y][x]!='.'&&g[y][x]!='\0'){
      int ny=y+(g[y][x]=='v')-(g[y][x]=='^');
      int nx=x+(g[y][x]=='>')-(g[y][x]=='<');
      g[y][x]='\0';
      y=ny;
      x=nx;
    }
    if(g[y][x]){
      cout<<x<<' '<<y<<endl;
    }else{
      cout<<"LOOP"<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>

int main(){
  int a,b;
  while(std::cin>>a>>b){
    if(!a&&!b)return 0;
    char c[101][101];
    for(int y=0;y<a;y++){
      std::string s;
      std::cin>>s;
      for(int x=0;x<b;x++)
        c[y][x] = s[x];
    }
    int r[101][101]={0},t_x=0,t_y=0;
    while(c[t_y][t_x] != '.'){
      switch(c[t_y][t_x]){
      case '>':
        t_x++;
        break;
      case '<':
        t_x--;
        break;
      case 'v':
        t_y++;
        break;
      case '^':
        t_y--;
        break;
      }
      if(r[t_y][t_x]>1)break;
      r[t_y][t_x]++;
    }
    if(r[t_y][t_x]>1)std::cout<<"LOOP"<<std::endl;
    else{std::cout<<t_x<<" "<<t_y;}
  }
}

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

#define MAX 10

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++: // 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 i=0; i<H; i++)
			for(int j=0; j<W; j++){
				char tmp;
				do{
					cin >> tmp;
				}while(tmp=='\n');
				til[i][j] = tmp;
		}

		bool flg[101][101];
		for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
				flg[i][j] = false;

		int x = 0;
		int y = 0;
		while(true){
			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{
				cout << x << ' ' << y << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<cstring>
using namespace std;
int W,H;
char fie[102][102];
int cost[102][102];
char df[]={'>','v','<','^'};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
  while(1){
    cin >> W >> H;
    memset(fie,-1,sizeof(fie));
    memset(cost,0,sizeof(cost));
    if(W==0 && H==0) break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> fie[j][i];
      }
    }
    int x=0,y=0;
    bool f=false;
    cost[x][y]=1;
    while(fie[x][y]!='.'){
      for(int i=0;i<4;i++){
	
	if(fie[x][y]==df[i]){
	  x+=dx[i];
	  y+=dy[i];
	}
      }
      if(cost[x][y]){
	f=true;
	break;
      }
      cost[x][y]=1;
    }
    if(!f) printf("%d %d\n",x,y);
    else puts("LOOP");
  }
}