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

C++: #include <iostream>

constexpr int dx[]={0,-1,0,1,0},dy[]={0,0,-1,0,1};

int h,w;

int board[100][100];

bool used[100][100];

void dfs(int x,int y) {
	used[y][x]=true;

	if(!board[y][x]){
		std::cout<<x<<' '<<y<<std::endl;
		return;
	}

	int nx=dx[board[y][x]]+x,ny=dy[board[y][x]]+y;

	if(used[ny][nx]){
		std::cout<<"LOOP"<<std::endl;
		return;
	}

	dfs(nx,ny);

	used[y][x]=false;
}

int main() {
	while(1){
		std::cin>>h>>w;
		if(h+w==0)
			break;
		char ch;
		for(int i=0;i<h;++i){
			for(int j=0;j<w;++j){
				std::cin>>ch;
				if(ch=='<')
					board[i][j]=1;
				else if(ch=='^')
					board[i][j]=2;
				else if(ch=='>')
					board[i][j]=3;
				else if(ch=='v')
					board[i][j]=4;
			}
		}
		dfs(0,0);
	}
	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>
#include<vector>
#include<string>
using namespace std;
int main(){
  while(true){
    int w,h;
    cin>>h>>w;
    if(!h&&!w)
      break;
    vector<string> room;
    for(int i=0;i<h;i++){
      string line;
      cin>>line;
      room.push_back(line);
    }
    int x,y;
    x=y=0;
    bool move = true;
    while(move){
      switch(room[y][x]){
      case'>':
	room[y][x] = '@';
	x++;
	break;
      case'<':
	room[y][x] = '@';
	x--;
	break;
      case'^':
	room[y][x] = '@';
	y--;
	break;
      case'v':
	room[y][x] = '@';
	y++;
	break;
      case'.':
	cout<<x<<" "<<y<<endl;
	move = false;
	break;
      case'@':
	cout<<"LOOP"<<endl;
	move = false;
	break;
      default:
	break;
      }
    }
  }
  return 0;
}

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

int x,y,H,W,c[110][110]/*d[110][110]*/;
string s;

int main(){
  while(true){
    for(int i=0;i<101;i++){
      for(int j=0;j<101;j++)
	{c[i][j]=6;}
    }

    scanf("%d%d",&H,&W);
    if(H==0&&W==0){break;}
    for(int i=0;i<H;i++){
      cin>>s;
      for(int j=0;j<W;j++){
	if(s.substr(j,1)==">"){c[i][j]=1;}
	if(s.substr(j,1)=="<"){c[i][j]=2;}	
	if(s.substr(j,1)=="^"){c[i][j]=3;}
	if(s.substr(j,1)=="v"){c[i][j]=4;}
	if(s.substr(j,1)=="."){c[i][j]=5;}
      }
    }///c[h][w]
    x=0;
    y=0;
    while(true){
      if(c[x][y]==1)
	{c[x][y]=0;
	  y++;}
      if(c[x][y]==2)
	{c[x][y]=0;
	  y--;}
      if(c[x][y]==3)
	{c[x][y]=0;
	  x--;}
      if(c[x][y]==4)
	{c[x][y]=0;
	  x++;}
      if(c[x][y]==5)
	{printf("%d %d\n",y,x);break;}
      if(c[x][y]==0)
	{printf("LOOP\n");break;}
    }
  }
}