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<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 (auto &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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

string mt[200];
int used[200][200];

int main() {
	int h,w;
	while(~scanf("%d %d\n",&h,&w),h){
		int x,y;
		for(y=0;y<h;y++){
			cin>>mt[y];
		}
		memset(used,0,sizeof(used));
		pint pos(0,0);
//cout<<"hoge"<<endl;
//cout<<mt[0][0]<<endl;
//cout<<'>'<<endl;
		while(mt[pos.second][pos.first]!='.'){
//cout<<pos.first<<" "<<pos.second<<endl;
			if(used[pos.second][pos.first]==1)break;
			used[pos.second][pos.first]=1;
			if(mt[pos.second][pos.first]=='>'){
				pos.first++;
			}else if(mt[pos.second][pos.first]=='<'){
				pos.first--;
			}else if(mt[pos.second][pos.first]=='v'){
				pos.second++;
			}else{
				pos.second--;
			}
		}
		if(mt[pos.second][pos.first]!='.')cout<<"LOOP";
		else cout<<pos.first<<" "<<pos.second<<endl;
	}
	return 0;
}

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

int main() {
    int H, W;
    
    while (cin >> H >> W && H + W != 0) {
        cin.get();
        
        char room[101][101];

        for (int h = 0; h < H; ++h) {
            for (int w = 0; w < W; ++w) {
                cin >> room[h][w];
            }
        }

        int x = 0, y = 0;
        bool loop = false;

        while (room[x][y] != '.' && !loop) {
            switch (room[x][y]) {
                case '!':
                    loop = true;
                    break;
                case '>':
                    room[x][y] = '!';
                    y++;
                    break;
                case '<':
                    room[x][y] = '!';
                    y--;                
                    break;
                case '^':
                    room[x][y] = '!';
                    x--;    
                    break;
                case 'v':
                    room[x][y] = '!';
                    x++;  
                    break;
            }
        }

        if (loop) {
            cout << "LOOP" << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }

    return 0;
}

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

int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0) return 0;
    char a[h][w];
    for (int i = 0; i < h; i++)
      scanf("%s", a[i]);

    int x, y, count;
    x = y = 0;
    count = 0;
    while (true) {
      if (count > 10000) {
	cout << "LOOP" << endl;
	goto loop_end;
      }
      if (a[y][x] == '>') x++;
      else if (a[y][x] == '<') x--;
      else if (a[y][x] == '^') y--;
      else if (a[y][x] == 'v') y++;
      else break;
      count++;
    }
    cout << x << ' ' << y << endl;
  loop_end: ;
  }
}

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

int main() {
  int x, y, mapx, mapy, tmp0, tmp1, flag;
  char map[101][101], pmap;
  scanf("%d%d",&mapx,&mapy);
  while (mapx+mapy) {
    for (tmp0 = 0;tmp0 < mapx;tmp0++) scanf("%s", map[tmp0]);
    x = 0, y = 0, flag = 1;
    while (flag && flag != 100) {
      pmap = map[x][y];
      map[x][y] = 1;
      if (pmap == '>') y++;
      else if (pmap == '<') y--;
      else if (pmap == '^') x--;
      else if (pmap == 'v') x++;
      else if (pmap == '.') flag = 0;
      else flag = 100;
    }
    if (flag) puts("LOOP");
    else printf("%d %d\n", y, x);
    scanf("%d%d", &mapx,&mapy);
  }
  return 0;
}