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 <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
	int w,h;
	while(cin>>h>>w,w&&h){
		vs f(h,string(w,' '));
		REP(i,h){
				cin>>f[i];
		}
		vvi v(h,vi(w));
		int x=0,y=0;
		while(1){
			if(v[y][x]){
				cout<<"LOOP"<<endl;
				goto loop;
			}
			char c=f[y][x];
			v[y][x]=1;
			switch(c){
			case '>':
				x++;
				break;
			case '<':
				x--;
				break;
			case 'v':
				y++;
				break;
			case '^':
				y--;
				break;
			default:
				goto end;
			}
		}
end:
		cout<<x<<" "<<y<<endl;
loop:
		;
	}

}

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

using namespace std;

const char arrow[] = {'>', '<', 'v', '^'};
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

int main(){
	int H, W;
	while(cin >> H >> W, H+W){
		vector<string> tile(101);
		bool visit[101][101];
		for(int i = 0; i < H; i++){
			cin >> tile[i];
		}
		int x = 0, y = 0;
		while(visit[y][x] != true){
			visit[y][x] = true;
			for(int i = 0; i < 4; i++){
				if(tile[y][x] == arrow[i]){
					x += dx[i];
					y += dy[i];
				}
			}
		}
		if(tile[y][x] == '.'){
			cout << x << ' ' << y << endl;
		}else{
			cout << "LOOP" << endl;
		}
	}

	return 0;
}

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

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int w,h;
  while(cin>>h>>w, h+w){
    char data[h][w+3];
    bool f[h][w];
    memset(f, 0, sizeof(f));
    REP(i,h) cin>>data[i];
    int x, y;
    x = y = 0;
    while(true){
      if(f[y][x]){
        puts("LOOP");
        break;
      }
      if(data[y][x] == '.'){
        printf("%d %d\n",x,y);
        break;
      }
      f[y][x] = true;
      switch(data[y][x]){
      case '>': x++; break;
      case '<': x--; break;
      case '^': y--; break;
      case 'v': y++; break;
      default: break;
      }
    }
  }
  return 0;
}

C++: #include <cstdio>
#include <cstring>

using namespace std;

int main(){
	int n,m,k,l,b[105][105]={0};
	char a[105][105];
	while(1){
		scanf("%d %d ",&n,&m);
		if( n==0 && m==0 ) break;
		k=0; l=0;
		for(int i=0 ; i<n ; i++ ){
			scanf("%s",&a[i]);	
		}
		while(1){
			if(a[k][l]=='.'){
				printf("%d %d\n",l,k);
				break;
			}
			if(b[k][l]==1){
				printf("LOOP\n");
				break;
			}
			if(a[k][l]=='>'){
				b[k][l]=1;
				l++;
				continue;
			}
			if(a[k][l]=='v'){
				b[k][l]=1;
				k++;
				continue;
			}
			if(a[k][l]=='<' ){
				b[k][l]=1;
				l--;
				continue;
			}
			if(a[k][l]=='^' ){
				b[k][l]=1;
				k--;
				continue;
			}
		}
	}
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 < 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 <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define debug(A) puts(A)
#define debugp(A,B) printf(A,B)
#define debugs(A,B) scanf(A,B)
using namespace std;

int main() {
  int mapx, mapy;
  int x, y, tmp0 = 0, tmp1 = 0, tmp2 = 0;
  char map[150][150] = {0}, tmpc = 1;
  scanf("%d %d", &mapx, &mapy);
  while (mapx+mapy) {
    scanf("%c", &tmpc);
    while (tmp0 < mapx) {
      tmp1 = 0;
      while (tmp1 < mapy) {
        scanf("%c", &map[tmp0][tmp1]);
        tmp1++;
      }
      scanf("%c", &tmpc);
      tmp0++;
    }
    tmp0 = 0, tmp1 = 0, tmp2 = 0, tmpc = 1;
    x = 0, y = 0;
    while (tmpc) {
      if (tmp2 == 2000) break;
      if (map[x][y] == '>') y++;
      else if (map[x][y] == '<') y--;
      else if (map[x][y] == '^') x--;
      else if (map[x][y] == 'v') x++;
      else if (map[x][y] == '.') tmpc = 0;
      // else tmpc = 0;
      tmp2++;
      // debugp("Debug: %c %d %d\n", map[x][y], (x+1), (y+1));
    }
    if (tmp2 == 2000) puts("LOOP");
    else printf("%d %d\n", (x+1), (y+1));
    scanf("%d %d", &mapx, &mapy);
  }
  return 0;
}

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

int main() {
    while (true) {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        char** field = new char* [h];
        for (int i = 0; i < h; i++) {
            field[i] = new char [w + 1];
        }
        for (int i = 0; i < h; i++) {
            cin >> field[i];
        }
        int x = 0, y = 0;
        char op = field[y][x];
        while (op != '.' && op != '0') {
            field[y][x] = '0';
            switch (op) {
            case '>':
                x++;
                break;
            case '<':
                x--;
                break;
            case '^':
                y--;
                break;
            case 'v':
                y++;
                break;
            }
            op = field[y][x];
        }
        if (op == '.') {
            cout << x << " " << y << endl;
        } else if (op == '0') {
            cout << "LOOP" << endl;
        }
        for (int i = 0; i < h; i++) {
            delete[] field[i];
        }
        delete[] field;
    }
}