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

int H, W;
char tile[101][101];

void magi(int y, int x);

int main()
{
  while (scanf("%d%d", &H, &W), W || H){
    for (int i = 0; i < H; i++){
      scanf("%s", tile[i]);
    }
    magi(0, 0);
  }

  return (0);
}

void magi(int y, int x)
{
  if (tile[y][x] == '.'){
    printf("%d %d\n", x, y);
  }
  else if (tile[y][x] == '0'){
    puts("LOOP");
  }

  if (0 <= x + 1 && x + 1 <= W - 1 && tile[y][x] == '>'){
    tile[y][x] = '0';
    magi(y, x + 1);
  }
  if (0 <= x - 1 && x - 1 <= W - 1 && tile[y][x] == '<'){
    tile[y][x] = '0';
    magi(y, x - 1);
  }
  if (0 <= y + 1 && y + 1 <= H + 1 && tile[y][x] == 'v'){
    tile[y][x] = '0';
    magi(y + 1, x);
  }
  if (0 <= y - 1 && y - 1 <= H - 1 && tile[y][x] == '^'){
    tile[y][x] = '0';
    magi(y - 1, x);
  }
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int h,w;
	while(cin>>h>>w,w||h){
		char a[h][w];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>a[i][j];
			}
		}
		bool flag=true;
		int i=0,j=0;
		while(flag){
			flag=true;
			if(a[i][j]=='v'){
				j++;
				a[i][j]='!';
			}
			if(a[i][j]=='>'){
				i++;
				a[i][j]='!';
			}
			if(a[i][j]=='<'){
				i--;
				a[i][j]='!';
			}
			if(a[i][j]=='^'){
				j--;
				a[i][j]='!';
			}
			if(a[i][j]=='.'){
				break;
			}
			if(a[i][j]=='!'){
				flag=false;
			}
		}
		if(!flag){
			cout<<"LOOP"<<endl;
		}
		else{
			cout<<i<<' '<<j<<endl;
		}
	}
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int W,H;
char fie[102][102];
int cost[102][102];
char df[]={'>','v','<','^'};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
  while(1){
    cin >> H >> W;
    memset(fie,-1,sizeof(fie));
    memset(cost,0,sizeof(cost));
    if(W==0 && H==0) break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> fie[j][i];
      }
    }
    int x=0,y=0;
    bool f=false;
    cost[x][y]=1;
    while(fie[x][y]!='.'){
      for(int i=0;i<4;i++){
	
	if(fie[x][y]==df[i]){
	  x+=dx[i];
	  y+=dy[i];
	}
      }
      if(cost[x][y]){
	f=true;
	break;
      }
      cost[x][y]=1;
    }
    if(!f) printf("%d %d\n",x,y);
    else puts("LOOP");
  }
}

C++: #include <iostream>
#include <string>
using namespace std;
bool Istraveled[100][100];
char data[100][100];

void solve(int h,int w) {
	Istraveled[h][w]=true;
	char x=data[h][w];
	if(x=='.') {
		cout<<w<<" "<<h<<endl;
	}
	else if(x=='^') {
		if(Istraveled[h-1][w]==true) {
			cout<<"LOOP"<<endl;
		}
		else {
			solve(h-1,w);
		}
	}
	else if(x=='v') {
		if(Istraveled[h+1][w]==true) {
			cout<<"LOOP"<<endl;
		}
		else {
			solve(h+1,w);
		}
	}
	else if(x=='>') {
		if(Istraveled[h][w+1]==true) {
			cout<<"LOOP"<<endl;
		}
		else {
			solve(h,w+1);
		}
	}
	else if(x=='<') {
		if(Istraveled[h][w-1]==true) {
			cout<<"LOOP"<<endl;
		}
		else {
			solve(h,w-1);
		}
	}
}

int main(void) {
	int h,w;
	string in;
	while(cin>>h>>w,h) {
		for(int i=0;i<h;i++) {
			cin>>in;
			for(int j=0;j<w;j++) {
				data[i][j]=in[j];
				Istraveled[i][j]=false;
			}
		}
		solve(0,0);
	}
	return 0;
}

C++: #include<iostream>

std::pair<char,bool> data[101][101];

int main(){
	int w,h;
	std::cin>>w>>h;
	while(w!=0&&h!=0){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				std::cin>>data[i][j].first;
				data[i][j].second=false;
			}
		}
		int x=0,y=0;
		while(true){
			if(data[y][x].second){
				std::cout<<"LOOP"<<std::endl;
				break;
			}else data[y][x].second=true;

			if(data[y][x].first=='^')y-=1;
			else if(data[y][x].first=='>')x+=1;
			else if(data[y][x].first=='v')y+=1;
			else if(data[y][x].first=='<')x-=1;

			if(data[y][x].first=='.'){
				std::cout<<x<<" "<<y<<std::endl;
				break;
			}
		}
		std::cin>>w>>h;
	}
	return 0;
}