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 pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using comd = complex<double>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

  template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}
char c[101][101];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W;
  while(cin >> H >> W){
    if(H+W == 0) break;
    set<pii> f;
    pii P(0,0);
    rep(i,H){
      rep(j,W){
        cin >> c[i][j];
      }
    }
    while(c[P.fi][P.se] != '.'){
      auto check = f.insert(P);
      if(c[P.fi][P.se] == '>'){
        P.se++;
      }
      else if(c[P.fi][P.se] == 'v'){
        ++P.fi;
      }
      else if(c[P.fi][P.se] == '^'){
        --P.fi;
      }
      else if(c[P.fi][P.se] == '<'){
        --P.se;
      }
      else{
        break;
      }
      if(!check.se ){
        cout << "LOOP" << endl;
        W = -1;
        break;
      }
    }
    if(W != -1){
      cout << P.se<< " " << P.fi<<endl;
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;

int main(){
    while (1){
        int h,w; cin>>h>>w;
        if(h+w==0)
            break;
        bool came[h][w]={},loop=0;
        string in[h];
        for(int i=0; i<h; i++){
            cin>>in[i];
        }
        int x=0,y=0;
        while (in[y][x]!='.'){
            if(came[y][x]){
                loop=1;
                break;
            }
            came[y][x]=1;
            switch (in[y][x]){
                case '>':
                    x++;
                    break;
                case '<':
                    x--;
                    break;
                case '^':
                    y--;
                    break;
                case 'v':
                    y++;
                    break;
            }
        }
        if(loop)
            cout<<"LOOP\n";
        else
            cout<<x<<" "<<y<<endl;
//      cout<<in[y][x]<<endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    int w,h;
    int i,j;
    while(1){
        cin >> h;
        cin >> w;
        if(w == 0 || h == 0) break;
        vector< vector<char> > v(101, vector<char>(101));
        for(j=0;j<h;++j){
            for(i=0;i<w;++i){
                cin >> v[i][j];
            }
        }
        int mi = 0, mj = 0;
        while(true){
            char c = v[mi][mj];
            v[mi][mj] = '#';
            if(c == '>') mi++;
            else if(c == '<') mi--;
            else if(c == '^') mj--;
            else if(c == 'v') mj++;
            else if(c == '#'){
                cout << "LOOP" << endl;
                break;
            } else if( c == '.' ){
                cout << mi << ' ' << mj << endl;
                break;
            }
        }
    }
    return 0;
}

C++: #include <iostream>

int main(int argc, char **argv)
{
	int h, w;
	int x = 0, y = 0;
	char tiles[100][100];
	bool throughed[100][100] = {};
	bool loop = false;
	bool end = false;
	while(std::cin >> h >> w, h+w != 0){
		x = 0;
		y = 0;
		for(int i = 0; i < 100; i++){
			for(int j = 0; j < 100; j++){
				throughed[j][i] = false;
			}
		}
		loop = false;
		end = false;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				std::cin >> tiles[j][i];
			}
		}
		while(true){
			if(throughed[x][y]){
				loop = true;
				break;
			}
			throughed[x][y] = true;
			switch(tiles[x][y]){
				case '.':
					end = true;
					break;
				case '^':
					y--;
					break;
				case 'v':
					y++;
					break;
				case '<':
					x--;
					break;
				case '>':
					x++;
					break;
			}
			if(end){
				break;
			}
		}
		if(loop){
			std::cout << "LOOP" << std::endl;
		}else{
			std::cout << x << " " << y << std::endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define SZ(n)  (int)n.size()
#define dump(x) cerr<<#x<<" = "<<(x)<<endl;
#define debug(x)cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define MP make_pair
#define PB push_back
	
	char ta[130][130];
	int h,w,ny=0,nx=0,cnt=0;
	bool ok(int y,int x,int ny,int nx){if(ny+y>=0&&ny+y<=h-1&&nx+x>=0&&nx+x<=w-1)return 1;else return 0;}
	int main(){

	while(cin>>h>>w,h+w){
	cnt=0;
	ny=nx=0;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>ta[i][j];
	while(true){
		//cout<<ny<<" "<<nx<<endl;
		if(ta[ny][nx]=='.'){cout<<nx<<" "<<ny<<endl;break;}
		if(cnt>=50000){cout<<"LOOP"<<endl;;break;}
		if(ta[ny][nx]=='>')nx++;
		else if(ta[ny][nx]=='<')nx--;
		else if(ta[ny][nx]=='^')ny--;
		else if(ta[ny][nx]=='v')ny++;
		cnt++;
	}
	for(int i=0;i<130;i++)for(int j=0;j<130;j++)ta[i][j]=' ';
	}
	return 0;
}