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 <iostream>
using namespace std;

int main(){
    char mymap[101][101];
    int x, y;
    int px = 0; int py = 0; int step = 0;
    while (1){
	cin >> x >> y;
	if (!x && !y) break;
	for (int i = 0; i < x; i++){
	    for (int j = 0; j < y; j++){
		cin >> mymap[i][j];
	    }
	}
/*	for (int i = 0; i < x; i++){
	for (int j = 0; j < y; j++){
	cout << mymap[i][j];
	}
	cout << endl;
	}
*/
	step = px = py = 0;
	while (mymap[px][py] != '.' && step <= x*y){
	    switch (mymap[px][py]){
		case '>':
		    py++; break;
		case 'v':
		    px++; break;
		case '<':
		    py--; break;
		case '^':
		    px--; break;
		default: break;
	    }
	    step++;
	}
	if (step <= x*y)
	    cout << py << " " << px << endl;
	else
	    cout << "LOOP" << endl;
    }
}

C++: #include <stdio.h>

char map[100][100];
int done[100][100];

int main(){
  while(1){
    int w,h;
    scanf("%d%d", &w, &h);

    if(w==0) break;

    int i,j;
    for(i=0;i<h;i++) for(j=0;j<w;j++){
       done[i][j] = 0;
       scanf(" %c", &map[i][j]);
      }

    int x,y;
    x = y = 0;
    
    while(!done[x][y]){
      if(map[x][y] == '.') break;
      done[x][y] = 1;
      if(map[x][y] == '>') y++;
      else if(map[x][y] == 'v') x++;
      else if(map[x][y] == '^') x--;
      else if(map[x][y] == '<') y--;
    }

    if(done[x][y]) puts("LOOP");
    else printf("%d %d\n", y, x);
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int MAX_H = 100;
const int MAX_W = 100;
char m[MAX_H+1][MAX_W+1];
int h, w;
bool used[MAX_H+1][MAX_W+1];

int main()
{
  while((cin >> h >> w) && h && w){
    rep(i, h) rep(j, w) used[i][j] = false;
    rep(i, h) rep(j, w) cin >> m[i][j];

    int hx = 0;
    int hy = 0;
    while(true){
    used[hx][hy] = true;
    if(m[hx][hy] == '>') hy += 1;
    if(m[hx][hy] == '<') hy -= 1;
    if(m[hx][hy] == '^') hx -= 1;
    if(m[hx][hy] == 'v') hx += 1;
    if(m[hx][hy] == '.'){ cout << hy << " " << hx << endl; break;}
    if(used[hx][hy]){ cout << "LOOP" << endl;  break; }
    }
  }

  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 == 20000) 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 <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;

int main(){
    int h,w;
    while(1){
        int h,w;
        scanf("%d %d",&h,&w);
        cin.ignore();
        if (h==0 & w==0){
            return 0;
        }
        char ma[100][100];
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                scanf(" %c",&ma[i][j]);
            }
        }
        int px,py;
        px = py = 0;
        while(1){
            // printf("%d %d %c\n",py,px,ma[py][px]);
            switch(ma[py][px]){
                case '>':
                    ma[py][px] = 'x';
                    px += 1;
                    break;
                case '^':
                    ma[py][px] = 'x';
                    py -= 1;
                    break;
                case '<':
                    ma[py][px] = 'x';
                    px -= 1;
                    break;
                case 'v':
                    ma[py][px] = 'x';
                    py += 1;
                    break;
            }
            if(ma[py][px] == 'x'){
                printf("LOOP\n");
                break;
            }else if (ma[py][px] == '.'){
                printf("%d %d\n", px,py);
                break;
            }
        }
    }
    return 0;
}

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

int main(){
	int w,h;
	string m[110];
	bool f[110][110], flag;
	
	while( cin >> h >> w , w, h ){
		flag = false;
		for(int y=0 ; y<h ; y++){
			m[y].clear();
			for(int x=0 ; x<w ; x++){
				f[y][x] = false;
			}
		}
		for(int y=0 ; y<h ; y++){
			cin >> m[y];
		}
		int x=0, y=0;
		while(1){
			if( m[y][x]=='>' ) x++;
			if( m[y][x]=='<' ) x--;
			if( m[y][x]=='v' ) y++;
			if( m[y][x]=='^' ) y--;
			
			if( m[y][x]=='.' || f[y][x] ){
				if( f[y][x] ) flag = true ;
				break;
			}
			f[y][x] = true;
		}
		(flag)? (cout << "LOOP" << endl) : (cout << x << " " << y << endl); 
	}
	return 0;
}

C++: #include<iostream>
#include<string>
char pos[100][100] = {};
int X, Y, mem[100][100] = {}, n, m;
int f(int x, int y) {
	if (mem[x][y] == 1) {
		return 1;
	}
	mem[x][y] = 1;
	if (pos[x][y] == '<') {
		if (y == 0)
			return 1;
		y -= 1;
	}
	else if (pos[x][y] == '>') {
		if (y == m - 1)
			return 1;
		y += 1;
	}
	else if (pos[x][y] == '^') {
		if (x == 0)
			return 1;
		x -= 1;
	}
	else if (pos[x][y] == 'v') {
		if (x == n - 1)
			return 1;
		x += 1;
	}
	else if (pos[x][y] == '.') {
		X = x;
		Y = y;
		return 0;
	}
	return f(x, y);
}
int main() {
	while (std::cin >> n >> m, n + m != 0) {
		X = 0, Y = 0;
		for (int i = 0; i < n; i += 1)
			for (int j = 0; j < m; j += 1) {
				std::cin >> pos[i][j];
				mem[i][j] = 0;
			}
		int ans = f(0, 0);
		if (ans == 1)
			std::cout << "LOOP" << std::endl;
		else std::cout << Y <<" "<< X << std::endl;
	}
	return 0;
}