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++: // 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;
 }

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

int H, W;
char tiles[110][110];

int main() {
  while (scanf("%d %d", &H, &W), H || W) {
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
	cin >> tiles[i][j];
      }
    }
    
    int x, y;
    x = y = 0;

    /*
    puts("debug");
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
	cout << tiles[i][j];
      }
      cout << endl;
    }
    puts("debugend");
    */
    
    while (tiles[y][x] != '.' && tiles[y][x] != '*') {   
      // printf("debug %d %d %c\n", x, y, tiles[y][x]);

      char c = tiles[y][x];
      tiles[y][x] = '*';
      if (c == '>') {
	x++;
      } else if (c == '<') {
	x--;
      } else if (c == '^') {
	y--;
      } else if (c == 'v') {
	y++;
      }

    }

    // printf("%c\n", tiles[y][x]);
    
    if (tiles[y][x] == '.') {
      printf("%d %d\n", x, y);
    } else {
      puts("LOOP");
    }
  }
}

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

using namespace std;

/*
タイルは5種類
> : 東
< : 西
^ : 北
v : 南
. : なし

現在地のタイルが東西南北なら移動、
ピリオドなら終了して位置を出力する。

ループの判断
１度到達した位置は記録しておく。
２回目に到達したらループと判定する。

*/


struct Position {
	int xPos;
	int yPos;
};

Position moveNorth(Position pos) {
	return Position{ pos.xPos, pos.yPos - 1 };
}

Position moveSouth(Position pos) {
	return Position{ pos.xPos, pos.yPos + 1 };
}

Position moveWest(Position pos) {
	return Position{ pos.xPos - 1, pos.yPos };
}

Position moveEast(Position pos) {
	return Position{ pos.xPos + 1, pos.yPos };
}


int main() {
	int h, w;
	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}
		Position hitoPos = {};
		vector<vector<char>> tiles(h);
		vector<vector<bool>> mark(h);
		for (int i = 0; i < h; i++) {
			tiles[i] = vector<char>(w);
			mark[i] = vector<bool>(w);
		}

		for (auto& a : tiles) {
			for (auto &b : a) {
				cin >> b;
			}
		}

		while (!mark[hitoPos.yPos][hitoPos.xPos]) {
			mark[hitoPos.yPos][hitoPos.xPos] = true;
			switch (tiles[hitoPos.yPos][hitoPos.xPos])
			{
			case '>':
				hitoPos = moveEast(hitoPos);
				break;
			case '<':
				hitoPos = moveWest(hitoPos);
				break;
			case '^':
				hitoPos = moveNorth(hitoPos);
				break;
			case 'v':
				hitoPos = moveSouth(hitoPos);
				break;
			}
		}
		if (tiles[hitoPos.yPos][hitoPos.xPos] == '.') {
			cout << hitoPos.xPos << ' ' << hitoPos.yPos << endl;
		}
		else {
			cout << "LOOP" << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    char d[101][101],ch;int w,h,i,j;
    while(cin>>h>>w,h){
        for(i=0;i<h;i++)for(j=0;j<w;j++)cin>>d[i][j];i=j=0;
        while(d[i][j]!='.'&&d[i][j]!='X'){
            ch=d[i][j];d[i][j]='X';
            switch (ch){
                case '>':j++;break;
                case '<':j--;break;
                case 'v':i++;break;
                case '^':i--;
            }
        }(d[i][j]=='.')?(cout<<j<<" "<<i<<endl):(cout<<"LOOP"<<endl);
    }
}

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

bool check[101][101]={false};
int h,w;
char mas[101][101]={0};
pair<int, int> func(){
	/*for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				cout << mas[i][j];
			}
			cout << endl;
		}*/
	for(int i=0; i<h;){
		for(int j=0; j<w;){
			if(check[i][j]==true) return make_pair(-1,-1);
			check[i][j]=true;
			//cout << i << " " << j << endl;
			if(mas[i][j]=='>') j++;
			if(mas[i][j]=='<') j--;
			if(mas[i][j]=='v') i++;
			if(mas[i][j]=='^') i--;
			if(mas[i][j]=='.') return make_pair(i,j);
		}
	}
}

int main(){
	
	
	
	while(1){
		cin >> h >> w;
		if(h==0 && w==0) break;
		for(int i=0; i<h; i++){
			scanf("%s",&mas[i]);
		}
		
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				check[i][j]=false;
			}
		}
		pair<int, int> a=func();
		if(a.first==-1) cout << "LOOP" << endl;
		else cout << a.second << " " << a.first << endl;
	}
	return 0;
}