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>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int h,w;
    while(cin >> h >> w){
        if(!h && !w) break;

        vector<string> map(h);
        rep(i,h) cin >> map[i];

        int i = 0, j = 0;
        while(1){
            if(map[i][j] == 'x'){
                cout << "LOOP" << endl;
                break;
            }
            if(map[i][j] == '.'){
                cout << j << " " << i << endl;
                break;
            }
            if(map[i][j] == '>'){
                map[i][j] = 'x';
                j++;
                continue;
            }
            if(map[i][j] == '<'){
                map[i][j] = 'x';
                j--;
                continue;
            }
            if(map[i][j] == '^'){
                map[i][j] = 'x';
                i--;
                continue;
            }
            if(map[i][j] == 'v'){
                map[i][j] = 'x';
                i++;
                continue;
            }
        }
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
#define MAX (256)

char field[MAX][MAX];

int main(){
	int w, h;
	while(cin >> w >> h, w || h){
		for(int i=0; i < w; i++){
			for(int j=0; j < h; j++){
				cin >> field[i][j];
			}
		}
		int x=0, y=0;
		while(1){
			switch(field[x][y]){
				case '>':
					field[x][y] = '#';
					y++;
					break;
				case 'v':
					field[x][y] = '#';
					x++;
					break;
				case '<':
					field[x][y] = '#';
					y--;
					break;
				case '^':
					field[x][y] = '#';
					x--;
					break;
				case '.':
					field[x][y] = '%';
					cout << y << ' ' << x << endl;
					break;
				case '#':
					field[x][y] = '%';
					cout << "LOOP" << endl;
					break;
			}
			if(field[x][y] == '%') break;
		}
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int h,w;

char M[101][101];

pair<int,int> f(int y,int x){
  pair<int,int> p;
  if(M[y][x]=='.'){
    p=mp(y,x);
    return p;
  }
  if(M[y][x]=='#'){
    p=mp(-1,-1);
    return p;
  }
  if(M[y][x]=='>'){
    M[y][x]='#';
    f(y,x+1);
  }else if(M[y][x]=='^'){
    M[y][x]='#';
    f(y-1,x);
  }else if(M[y][x]=='<'){
    M[y][x]='#';
    f(y,x-1);
  }else if(M[y][x]=='v'){
    M[y][x]='#';
    f(y+1,x);
  }
}

signed main(){
  while(cin>>h>>w,h){
    rep(i,h)rep(j,w)cin>>M[i][j];
    pair<int,int> P=f(0,0);
    if(P.fir==-1&&P.sec==-1){
      cout<<"LOOP"<<endl;
    }else{
      cout<<P.sec<<' '<<P.fir<<endl;
    }
  }
  return 0;
}

C++: #include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>


using namespace std;

void Solution()
{
    int sideH, sideW;
    
    char cha[101][101];
    
    int masu;
    int x, y; //in this problem y axis is sideH, x axis is sideW
    
    while (cin>>sideH>>sideW)
    {
        if (sideW == 0 && sideH == 0)
        {
            break;
        }
        
        for (y = 0; y < sideH; y++) //save the data to array
        {
            cin>>cha[y];
        }
        
        masu = x = y = 0; // start from 0, 0
        
        while (true)
        {
            if (cha[y][x] == '.')
            {
                cout<<x<<" "<<y<<endl;
                break;
            }
            
            switch (cha[y][x]) // walk automatically by symbol
            {
                case '^':
                    y--;
                    break;
                case '<':
                    x--;
                    break;
                case 'v':
                    y++;
                    break;
                case '>':
                    x++;
                    break;
            }
            
            masu++;
            
            if (masu > sideH * sideW) // means infinite loop, or out of the limit
            {
                cout<<"LOOP"<<endl;
                break;
            }
        }
    }

}

int main()
{
    Solution();
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

#define MP make_pair<int,int>

int mp[830][252];
bool vstd[830][252];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int dw[255];

int main(){
  dw['.'] = -1;
  dw['>'] = 0;
  dw['<'] = 2;
  dw['v'] = 1;
  dw['^'] = 3;
  while(true){
    int h,w;
    cin>>h>>w;
    if(!(h+w))break;
    REP(i,h)REP(j,w)vstd[i][j] = false;
    REP(i,h){
      string s;
      cin>>s;
      REP(j,w) mp[i][j] = dw[s[j]];
    }
    int x,y;
    x=y=0;
    while(mp[y][x]!=-1){
      if(vstd[y][x]){
        x=y=-1;
        break;
      }
      vstd[y][x] = true;
      int c = mp[y][x];
      x += dx[c];
      y += dy[c];
    }
    if(x==-1){
      cout<<"LOOP"<<endl;
    }else{
      printf("%d %d\n",x,y);
    }
  }
  return 0;
}

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!=10001){
      i++;
      if(i==10000)
	cout<<"LOOP"<<endl;
      if(tile[now.first][now.second]=='.'){
	cout<<now.first<<" "<<now.second<<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;
}