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(void){
	char array[100][100];
	int i,j,w,h;
	while(1){
		cin >> w;
		cin >> h;
		if(w == 0 || h == 0) break;
		for(i=0;i<w;i++) for(j=0;j<h;j++) cin >> array[i][j];		
		i=0;j=0;
		while(1){
			if(array[i][j] == '>'){ array[i][j] = '/'; j++;}
			else if(array[i][j] == '<'){ array[i][j] = '/'; j--;}
			else if(array[i][j] == '^'){ array[i][j] = '/'; i--;}
			else if(array[i][j] == 'v'){ array[i][j] = '/'; i++;}
			else break;
		}
		if(array[i][j] == '/'){ cout << "LOOP" << endl; }
		else { cout << j << " " << i << endl; }
	}
	return 0;
}

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

int main(){
  int h, w;
  while(true){
    cin >> h >> w;
    if(h==0 && w==0)
      break;
    vector<string> m;
    int c[h][w];
    string s;
    for(int k=0; k<h; k++){
      cin >> s;
      m.push_back(s);
      for(int l=0; l<w; l++)
	c[k][l] = 0;
    }
    int i=0, j=0;
    bool lp = false;
    while(true){
      if(c[i][j] == 1){
	lp=true; break;
      }
      else if(m[i][j] == '.')
	break;
      else if(m[i][j] == '>'){
	c[i][j] = 1;
	j++;
      }
      else if(m[i][j] == 'v'){
	c[i][j] = 1;
	i++;
      }
      else if(m[i][j] == '<'){
	c[i][j] = 1;
	j--;
      }
      else if(m[i][j] == '^'){
	c[i][j] = 1;
	i--;
      }
    }
    if(lp){
      cout << "LOOP\n";
    }
    else
      cout << j << " " << i << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <set>
using namespace std;
bool 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 '>':
      return calc(field, y + 1, x);
      break;
    case '<':
      return calc(field, y - 1, x);
      break;
    case '^':
      return calc(field, y, x - 1);
      break;
    case 'v':
      return calc(field, y, x + 1);
      break;
    case '.':
      resultx = x;
      resulty = y;
      return true;
  }
}

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 << j << " " << i << std::endl;
                i = j = 0;
            }
        }
    }
    
    return 0;
}

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