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<string>

using namespace std;
char map[100][100];
int H, W;
int x = 0, y = 0;
int rog[100][100];
bool check(){
	if (rog[x][y] == 0){
		cout << "LOOP" << endl;
		return true;
	}
	else{
		return false;
	}
}
int main(){
	
	while (1){

		int x = 0, y = 0;
		map[100][100] = {};
		cin >> H >> W;

		if (H == 0 && W == 0){ break; }
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> map[i][j];
				rog[i][j] = 1;
			}
		}
		while (1){
			if (check() == true){ break; }
			if (map[x][y] == '>'){
				x++;
			}
			else if(map[x][y]=='v'){
				y--;
			}
			else if (map[x][y] == '<'){
				x--;;
			}
			else if (map[x][y] == '^'){
				y++;
			}
			else if (map[x][y] == '.'){
				cout << x << " " << y << endl;
				break;
			}
			
			rog[x][y] = 0;

		}
	}
	return 0;
}

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

#define FILED (-1)

enum TILE_TYPE{
  TILE_NONE = 0,
  TILE_UP,
  TILE_DOWN,
  TILE_RIGHT,
  TILE_LEFT,

  TILE_TYPE_NUM
};
static const char tile_type[TILE_TYPE_NUM] {
  '.',
  '^',
  'v',
  '>',
  '<'
};
int get_tile_type(char data) {
  for (int i = 0; i < TILE_TYPE_NUM; i++)
    if (data == tile_type[i])
      return i;
  return FILED;
}

struct Tile {
public:
  Tile(int _type) : type(_type), entered(false) {}
  
  void  SetType(int _type) { type = _type; }
  int   GetType(void)      { return type; }
  bool  StepOn(void) {
    bool has_entered = entered;
    entered = true;

    return has_entered;
  }
private:
  int   type;
  bool  entered;
};

struct Pos {
public:
  Pos(int _x, int _y) : x(_x), y(_y) {}
  bool operator ==(const Pos _pos) { 
    return this->x == _pos.x && this->y == _pos.y; 
  }

  int x;
  int y;
};

class TileSet {
public:
  TileSet() { arr.reserve(MAX_ARRAY_SIZE); }
  void Resize(const int h,const int w)
  {
    // ????´???°????¨??????????TILE_NONE??§?????????
    arr.resize(h);
    for (int i = 0; i < h; i++) {
      arr[i].resize(w, TILE_NONE);
    }
  }
  void Set(const int x, const int y, const int data)
  {
    assert(data != FILED);

    arr[x][y].SetType(data);
  }
  Pos Move(Pos pos)
  {
    switch (arr[pos.x][pos.y].GetType())
    {
    case TILE_NONE:
      return pos;
    case TILE_UP:
      return Pos(pos.x, pos.y - 1);
    case TILE_DOWN:
      return Pos(pos.x, pos.y + 1);
    case TILE_LEFT:
      return Pos(pos.x - 1, pos.y);
    case TILE_RIGHT:
      return Pos(pos.x + 1, pos.y);
    default:
      // ?????????????????£??????????????????
      return pos;
    }
  }

  // ????????????????¨????
  Pos EnterRoom(void)
  {
    Pos pos(0,0);

    while (1)
    {
      Pos now_pos = pos;
      pos = Move(pos);
      //cout << pos.x << " " << pos.y << endl;
      // ??????????????¢????????´?????????????????????
      if (now_pos == pos) return pos;
      // ????????????????????´??????????????????
      if (arr[pos.x][pos.y].StepOn()) return Pos(FILED,FILED);
    }
  }
private:
  static const int MAX_ARRAY_SIZE = 100 * 100;

  vector< vector<Tile> > arr;
  int now_tile_x;
  int now_tile_y;
};

int main() {
  // ???????????????????????\???
  int H, W;
  while(1){
    cin >> H >> W;
    // 0 0 ?????\??????????????¨??????
    if (!(H+W))  break;

    TileSet tile_set;
    tile_set.Resize(W, H);
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        char tile_data;
        cin >> tile_data;
        tile_set.Set(x, y, get_tile_type(tile_data));
      }
    }

    // ??????
    Pos pos = tile_set.EnterRoom();

    // ????????¨??????????????£?????????
    if (pos.x == FILED)
      cout << "LOOP" << endl;
    // ?§???????????????????
    else
      cout << pos.x << " " << pos.y << endl;
  }
}

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

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;
		std::memset(board,0,sizeof(board));
		std::memset(used,0,sizeof(used));
		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 <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

int main() {
	char tile[100][100];
	bool flag[100][100];
	int h, w, x, y;

	while (cin >> h >> w, h || w) {
		memset(tile, 0, sizeof(tile));
		memset(flag, 0, sizeof(flag));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> tile[i][j];
			}
			getchar();
		}
		x = 0; y = 0;
		while (1) {
			if (flag[y][x])
				break;
			else
				flag[y][x] = 1;

			switch (tile[y][x]) {
			case '>':
				x++;
				break;
			case '<':
				x--;
				break;
			case '^':
				y--;
				break;
			case 'v':
				y++;
				break;
			}
		}
		if (tile[y][x] == '.')
			cout << x << ' ' << y << endl;
		else
			cout << "LOOP" << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define SZ(n)  (int)n.size()
#define dump(x) cerr<<#x<<" = "<<(x)<<endl;
#define debug(x)cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define MP make_pair
#define PB push_back
	
	char ta[30][30];
	int h,w,ny=0,nx=0,cnt=0;
	bool ok(int y,int x,int ny,int nx){if(ny+y>=0&&ny+y<=h-1&&nx+x>=0&&nx+x<=w-1)return 1;else return 0;}
	int main(){

	while(cin>>h>>w,h+w){
	cnt=0;
	ny=nx=0;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>ta[i][j];
	while(true){
		//cout<<ny<<" "<<nx<<endl;
		if(ta[ny][nx]=='.'){cout<<nx<<" "<<ny<<endl;break;}
		if(cnt>=10000){cout<<"LOOP"<<endl;;break;}
		if(ta[ny][nx]=='>')nx++;
		else if(ta[ny][nx]=='<')nx--;
		else if(ta[ny][nx]=='^')ny--;
		else if(ta[ny][nx]=='v')ny++;
		cnt++;
	}
	for(int i=0;i<30;i++)for(int j=0;j<30;j++)ta[i][j]=' ';
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define o(a) cout<<a<<endl
using namespace std;

int main(){
	int h,w;
	while(1){
		cin>>h>>w;
		if(h==0&&w==0) break;
		char s[101][101];
		//vector<string> s(h);
		rep(i,0,h) rep(j,0,w) cin>>s[i][j];
		int y=0,x=0;
		bool f=0;
		//o(s[0][0]);
		for(int i=0;;i++){
			char c=s[y][x];
			//cout<<c<<endl;
			if(c=='>') x++;
			else if(c=='<') x--;
			else if(c=='^') y--;
			else if(c=='v') y++;
			else if(c=='.'){
				f=1; break;
			}
			//cout<<i<<endl;
			if(i>h*w) break;
		}
		if(f) cout<<x<<" "<<y<<endl;
		else cout<<"LOOP"<<endl;
	}
}