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 <stdio.h>

int main() {
  int i, j, w, h;
  char c, m[101][101];
  bool b[101][101], loop;

  while (1) {
    scanf("%d %d", &w, &h);
    if (!w && !h) break;
    for (i=0; i<h; i++) {
      for (j=0; j<w; j++) {
        do {
        scanf("%c", &c);
        m[i][j] = c;
        } while (c=='\n'||c=='\r');
      }
    }
    for (i=0; i<h; i++) {
      for (j=0; j<w; j++) {
        b[i][j] = false;
      }
    }
    i = j = 0;
    loop = false;
    while (1) {
      if (b[i][j]) {
        loop = true;
        break;
      }
      b[i][j] = true;
      c = m[i][j];
      if (c == '>') ++j;
      else if (c == '<') --j;
      else if (c == '^') --i;
      else if (c == 'v') ++i;
      else break;
    }
    if (!loop) {
      printf("%d %d\n", j, i);
    } else {
      printf("LOOP\n");
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int h,w;
    while(cin>>h>>w, h+w){
        vvc v(h,vc(w));
        rep(i,h)rep(j,w)cin>>v[i][j];
        pii now=pii(0,0);
        int cnt=0; bool flag=true;
        for(;cnt<=10000000;cnt++){
            if(v[now.first][now.second]=='>')now=pii(now.first,now.second+1);
            else if(v[now.first][now.second]=='<')now=pii(now.first,now.second-1);
            else if(v[now.first][now.second]=='^')now=pii(now.first-1,now.second);
            else if(v[now.first][now.second]=='v')now=pii(now.first+1,now.second);
            else break;
            if(cnt==10000000) {flag=false; puts("LOOP");}
        }
        if(flag)cout<<now.second<<" "<<now.first<<endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
int GCD(int a, int b){
    if(b==0) return a;
    return GCD(b, a%b);
}
int H, W;
int main() {
    while(cin>>H>>W, H||W){
        vector<string> field;
        bool check[H][W];
        for(int i=0; i<H; ++i){
            for(int j=0; j<W; ++j){
                check[i][j]=false;
            }
        }
        cin.ignore();
        for(int i=0; i<H; ++i){
            string str; getline(cin, str);
            field.push_back(str);
        }
        int x=0, y=0;
        while(1){
            check[y][x]=true;
            
            if(field[y][x]=='.'){
                cout << x << " " << y << endl;
                break;
            }
            if(field[y][x]=='>') {
                if(check[y][x+1]) {
                    cout << "LOOP" << endl;
                    break;
                }
                x++; continue;
            }
            if(field[y][x]=='v'){
                if(check[y+1][x]) {
                    cout << "LOOP" << endl;
                    break;
                }
                y++; continue;
            }
            if(field[y][x]=='^'){
                if(check[y-1][x]) {
                    cout << "LOOP" << endl;
                    break;
                }
                y--; continue;
            }
            if(field[y][x]=='<'){
                if(check[y][x-1]) {
                    cout << "LOOP" << endl;
                    break;
                }
                x--; continue;
            }
        }
        
    }
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, -1, 1};
string IntToStr(int);


int main(void){
	int h, w;
	while(cin >> h >> w, h){
		char S[103][103];
		int map[102][102];
		fill_n(*map, 102*102, -1);
		rep(i, h){
			cin >> S[i];
			rep(j,w){
				if(S[i][j] == '>')map[i][j] = 0;
				else if(S[i][j] == '<')map[i][j] = 1;
				else if(S[i][j] == '^')map[i][j] = 2;
				else if(S[i][j] == 'v')map[i][j] = 3;
			}

		}
		int memo[102][102];
		fill_n(*memo, 102*102, 0);
		int x = 0;
		int y = 0;
		int cnt = 0;
		while(1){
			if(S[y][x] == '.'){
				cout << x << " " << y << endl;
				break;
			}
			if(memo[y][x] == 1 && cnt != 0){
				FIN("LOOP");
				break;
			}
			int dir = map[y][x];
			memo[y][x] = 1;
			x += dx[dir];
			y += dy[dir];
			cnt++;
		}
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair



int main(){
    typedef vector<string> vs;
    int h,w;
    while(cin>>h>>w, h|w){
        vs G(a);
        for(auto & a: G) cin>>a;

        vector<vector<bool>> vis(vector<bool>(w,false),h);
        int cx = 0, cy = 0;
        const int dx[] = {1,0,-1,0};
        const int dy[] = {0,-1,0,1};

        map<char,int> m;
        m['>'] = 0, m['^'] = 1, m['<'] = 2, m['v'] = 3;

        while(1){
            if(vis[cy][cs]){
                cout << "LOOP" << endl;
                goto end;
            }
            vis[cy][cx] = true;
            char c = G[cy][cx];
            if(c=='.'){
                cout << cx << " " << cy << endl;
                goto end;
            }
            cx += dx[m[c]], cy += dy[m[c]];
        }
    end:;
    }
}