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>

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

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int h, w;
  map<char, pii> m = {
    {'>', mp(0, 1)}, {'v', mp(1, 0)}, {'<', mp(0, -1)}, {'^', mp(-1, 0)}};
  while (cin >> h >> w, h) {
    vs s(h);
    rep(i, h) cin >> s[i];
    int i = 0, j = 0;
    for (;;) {
      if (s[i][j] == '*') {
        cout << "LOOP" << endl;
        goto next;
      }
      if (s[i][j] == '.') {
        cout << j << ' ' << i << endl;
        goto next;
      }
      pii p   = m[s[i][j]];
      s[i][j] = '*';
      i += p.fi;
      j += p.se;
    }
  next:;
  }
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int w,h;
   bool flag=false;
   char map[100+5][100+5];
   while(cin>>w>>h&&(w||h))
   {
     for(int i=0;i<h;i++)
     {
       for(int j=0;j<w;j++)
       {
         cin>>map[i][j];        
       }        
     }               
     int step=0;
     int x=0;
     int y=0;
     while(1)
     {
       if(map[x][y]=='>') 
       {
         x++;
         step++;
         cout<<">"<<" ";                      
       }        
       if(map[x][y]=='<')
       {
         x--;
         step++;   
         cout<<"<"<<" ";                   
       }
       if(map[x][y]=='v')
       {
         y++;
         step++;         
         cout<<"v"<<" ";             
       }
       if(map[x][y]=='^')
       {
         y--;
         step++;         
         cout<<"^"<<" ";             
       }
       if(step>(w*h))
       {
         flag=true;
         break;            
       }
       if(map[x][y]=='.')
       {
         break;                  
       }
       if(flag) break;
     }        
     if(flag) cout<<"LOOP"<<endl;
     else cout<<x<<" "<<y<<endl;
   }
   //while(1);
   return 0;
 }