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 <bits/stdc++.h>
using namespace std;

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int main() {

more:
  int h, w; cin >> h >> w;
  cin.ignore();
  if (!h && !w) return 0;

  char f[h][w];
  rep (i, h) {
    rep (j, w) {
      char c = getchar();
      f[i][j] = c;
      if (! (c == '.' || c == 'v' || c == '^' || c == '<' || c == '>') ) {
        trace(cons(cons(i,j), c));
      }
      assert(c == '.' || c == 'v' || c == '^' || c == '<' || c == '>');
    }
    cin.ignore();
  }

  vector<pair<int, int>> history;

  int i = 0, j = 0;
  for (; f[i][j] != '.'; ) {
    switch (f[i][j]) {
      case '>': ++j; break;
      case '<': --j; break;
      case 'v': ++i; break;
      case '^': --i; break;
    }

    for (auto&x : history) {
      if (car(x) == i && cdr(x) == j) {
        cout << "LOOP" << endl;
        goto more;
      }
    }
    history.push_back(cons(i, j));
  }
  cout << (j) << ' ' << (i) << endl;

  goto more;
}

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

int main()
{
	bool f;
	int w,h,x,y;
	char t[128][128];

	while(cin >> h >> w, (h||w))
	{
		for(int i=0; i<h; i++)
		{
			cin >> t[i];
		}
	
		f=true;
		x=y=0;
		while(f)
		{
			switch(t[y][x])
			{
				case 0:
					cout << "LOOP" << endl;
					f=false;
					break;

				case '.':
					cout << x << " " << y << endl;
					f=false;
					break;

				case '>':
					t[y][x] = 0; x++;
					break;

				case '<':
					t[y][x] = 0; x--;
					break;

				case 'v':
					t[y][x] = 0; y++;
					break;

				case '^':
					t[y][x] = 0; y--;
					break;
			}
		}

	}
	return 0;
}

C++: #include<iostream>

std::pair<char,bool> data[101][101];

int main(){
	int h,w;
	while(std::cin>>h>>w){
		if(w==0&&h==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				std::cin>>data[i][j].first;
				data[i][j].second=false;
			}
		}
		int x=0,y=0;
		while(true){
			if(data[y][x].second){
				std::cout<<"LOOP"<<std::endl;
				break;
			}else data[y][x].second=true;

			if(data[y][x].first=='^')y--;
			if(data[y][x].first=='>')x++;
			if(data[y][x].first=='v')y++;
			if(data[y][x].first=='<')x--;

			if(data[y][x].first=='.'){
				std::cout<<x<<" "<<y<<std::endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#define REP(i, m, n) for(int i = m; i < static_cast<int>(n); ++i)
int main()
{
    int height, width;
    std::vector<std::string> tile = {">", "<", "^", "v", "."};
    
    while (std::cin >> height >> width) {
        if (height == 0 && width == 0) {
            break;
        }
        
        std::vector< std::vector<std::string> > table;
            
        REP(i, 0, height) {
        table.push_back( std::vector<std::string>() );
            
        REP(j, 0, width) {
            std::string data;
            std::cin >> std::setw(1) >> data;
            table[i].push_back(data);
        }
    }
            
        
        bool flag = true;

        while (flag){
            static int i = 0;
            static int j = 0;
            
            if (table[i][j] == tile[0]) {
                table[i][j] = ",";
                j++;
                continue;
            } else if (table[i][j] == tile[1]) {
                table[i][j] = ",";
                j--;
                continue;
            } else if (table[i][j] == tile[2]) {
                table[i][j] = ",";
                i--;
                continue;
            } else if (table[i][j] == tile[3]) {
                table[i][j] = ",";
                i++;
                continue;
            } else if (table[i][j] == ",") {
                flag = false;
                std::cout << "LOOP" << std::endl;
                i = j = 0;
            } else {
                flag = false;
                std::cout << i << " " << j << std::endl;
                i = j = 0;
            }
        }
    }
    
    return 0;
}

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

int H, W;

void solve() {
	string b[100];
	for (int i = 0; i < H; i++) {
		cin >> b[i];
	}

	bool visited[100][100] = {0};
	int x = 0, y = 0;

	while (b[y][x] != '.') {
		if (visited[y][x]) {
			cout << "LOOP" << endl;
			return;
		}
		visited[y][x] = true;
		if (b[y][x] == '^') y--;
		if (b[y][x] == 'v') y++;
		if (b[y][x] == '<') x--;
		if (b[y][x] == '>') x++;
	}

	cout << x << " " << y << endl;
}

int main() {
	while (cin >> H >> W , H) {
		solve();
	}
}

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

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

int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

char t[]={'<','^','>','v'};

char f[101][101];
bool v[100][100];
int X,Y;

bool dfs()
{
	if(v[X][Y]) return false;
	v[X][Y]=1;
	if(f[X][Y]=='.') return true;
	
	for(int i=0; i<4; i++)
	{
		if(t[i]==f[X][Y]) 
		{
			X+=dx[i];
			Y+=dy[i];
		}
	}
	return dfs();
}

int main()
{
	int H,W;
	while(cin >> H >> W, (H||W))
	{
		memset(v,0,sizeof(v));
		for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
			cin >> f[j][i];
			
		X=0; Y=0;
		
		bool f=dfs();
		if(f) cout << X << " " << Y << endl;
		else cout << "LOOP" << endl;
		
	}
}