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;

int main() {
    int tate,yoko;
    char panel;
    
    while(1){
     cin>>tate>>yoko;
        if(tate==0&&yoko==0)break;
               int move[105][105]={};
        for(int i=0; i<tate; i++){
            for(int s=0;s<yoko; s++){
                cin>>panel;
                if(panel=='<')move[i][s]=1;
                if(panel=='>')move[i][s]=2;
                if(panel=='^')move[i][s]=3;
                if(panel=='v')move[i][s]=4;
            }
        }
        int movet,movey=0;
        
        while(1){
            if(move[movet][movey]==5){
                cout<<"LOOP"<<endl;
                break;
            }

            if(move[movet][movey]==1){
                move[movet][movey]=5;
                movey--;
            }
            if(move[movet][movey]==2){
                move[movet][movey]=5;
                movey++;
            }
            if(move[movet][movey]==3){
                move[movet][movey]=5;
                movet--;
            }
            if(move[movet][movey]==4){
                move[movet][movey]=5;
                movet++;
            }
            if(move[movet][movey]==0){
                cout<<movey<<" "<<movet<<endl;
                break;
            }
            cout<<movey<<" "<<movet<<endl;
                    }
        }
    return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	int h,w,x,y;
	char dp[150][150];
	while(true){
	cin>>h>>w;
	if(h==0&&w==0)
		break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>dp[i][j];
		}
	}
	x=0,y=0;
	int i=0;
	bool loop=false;
	while(true){
		if(dp[x][y]=='>')
			y+=1;
		if(dp[x][y]=='<')
			y-=1;
		if(dp[x][y]=='^')
			x-=1;
		if(dp[x][y]=='v')
			x+=1;
		if(dp[x][y]=='.')
			break;
		i++;
		if(i==h*w){
			cout<<"LOOP"<<endl;
			loop=true;
			break;
		}
	}
	if(loop==false)
	cout<<y<<" "<<x<<endl;
	}
	return 0;
}

C++: loop do
  n,m=gets.split.map(&:to_i)
  break if n==0
  px,py,cnt=0,0,0
  arr=Array.new()
  n.times do 
    arr<<gets.chomp.split("")
  end
  loop do
    case arr[py][px]
    when "<" then px-=1
    when ">" then px+=1
    when "^" then py-=1
    when "v" then py+=1
    else break
    end
    cnt+=1
    break if cnt>n*m
  end
  puts cnt>n*m ? "LOOP": "#{px} #{py}"
end

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <set>
using namespace std;
void calc(vector<vector<char> >, int y, int x);
int resultx;
int resulty;
set<string> passed;

int main() {
  while(true) {
  int width, height;
  cin >> width >> height;
  if(width == 0 && height == 0) break;
  vector<vector<char> > field(width, vector<char>(height));
  for(int w = 0; w < width; ++w) {
    for(int h = 0; h < height; ++h) {
      cin >> field[w][h];
    }
  }
  if(calc(field, 0, 0)) cout << resulty << " " << resultx << endl;
  }
  return 0;
}

bool calc(vector<vector<char> > field, int y, int x) {
  stringstream ss;
  ss << y << ',' << x;
  // cout << ss.str() << endl;
  if(passed.find(ss.str()) != passed.end()) {
    cout << "LOOP" << endl;
    return false;
  }
  passed.insert(ss.str());
  switch(field[x][y]) {
    case '>':
      calc(field, y + 1, x);
      break;
    case '<':
      calc(field, y - 1, x);
      break;
    case '^':
      calc(field, y, x - 1);
      break;
    case 'v':
      calc(field, y, x + 1);
      break;
    case '.':
      resultx = x;
      resulty = y;
      return true;
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

string comp(int x, int y)
{
	string res;

	res += char(x + '0');
	res += " ";
	res += char(y + '0');

	return res;
}

string rec(vector<string>& field, pint pos)
{
	int buf = field[pos.first][pos.second];
	field[pos.first][pos.second] = 0;
	
	switch(buf)
	{
	case '.' :
		return comp(pos.second, pos.first);
		
	case '>' :
		return rec(field, mp(pos.first, pos.second + 1));

	case '<' :
		return rec(field, mp(pos.first, pos.second - 1));

	case '^' :
		return rec(field, mp(pos.first - 1, pos.second));

	case 'v' :
		return rec(field, mp(pos.first + 1, pos.second));

	default :
		return "LOOP";
	}
}

int main()
{
	int w, h;
	while(cin >> h >> w && w)
	{
		vector<string> field(h);

		rep(i, h)
			cin >> field[i];

		cout << rec(field, mp(0, 0)) << endl;
	}
}

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

#define rep(i,n) for(int i=0;i<n;++i)
#define mkp make_pair
#define F first
#define S second
int main(){
	int h,w;
	while(cin>>h>>w,h||w){
		vector<vector<int> > vv(h,vector<int>(w));
		// cout<<vv.size()<<" "<<vv[0].size()<<endl;
		pair<int,int> pos=mkp(0,0);
		vector<string> vs(h);
		rep(i,h){
			rep(j,w){
				vv[i][j]=1;
			}
		}
		rep(i,h) cin>>vs[i];
		bool flag=true;
		while(vv[pos.F][pos.S]){
			// cout<<vs[pos.F][pos.S]<<endl;
			vv[pos.F][pos.S]=0;
			int x=pos.F,y=pos.S;
			if(vs[x][y]=='.'){
				cout<<y<<" "<<x<<endl;
				flag=false;
				break;
			}
			if(vs[x][y]=='<') pos.S--;
			else if(vs[x][y]=='>') pos.S++;
			else if(vs[x][y]=='^') pos.F--;
			else pos.F++;
		}
		if(flag) cout<<"LOOP\n";
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

	int w, h;

	while(cin >> w >> h) {
		if(!w&&!h) {
			break;
		}
		char s[100][100];
		for(int i=0; i<w; i++) {
			for(int j=0; j<h; j++) {
				cin >> s[i][j];
			}
		}
		int c=0, x=0, y=0;
		while(c<w*h) {
			(s[x][y]=='>') && y++;
			(s[x][y]=='<') && y--;
			(s[x][y]=='^') && x--;
			(s[x][y]=='v') && x++;
			if(s[x][y]=='.') {
				break;
			}
			c++;
		}
		if(c!=w*h) {
			cout << y << " " << x << endl;
		}
		else {
			cout << "LOOP" << endl;
		}
	}

	return 0;

}