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 <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

void solve105(int H, int W) {
    vector<vector<int>> visited(H, vector<int>(W,0));
    vector<vector<char>> floor(H, vector<char>(W,0));
    string s;
    REP(i,H) {
        cin >> s;
        REP(j,W) {
            floor[i][j] = s[j];
        }
    }
    int x = 0; int y = 0;
    while (floor[y][x] != '.') {
        if (visited[y][x]) {
            cout << "LOOP" << endl;
            return;
        }
        visited[y][x] = 1;
        if (floor[y][x] == '>') {
            x++;
        }else if (floor[y][x] == '<') {
            x--;
        }else if (floor[y][x] == 'v') {
            y++;
        }else {
            y--;
        }
    }
    cout << x << " " << y << endl;
}

int main() {
    int H, W;
    while (cin >> H >> W, H + W) {
        solve105(H, W);
    }
}

C++: #include<cstdio>
using namespace std;
int main(){
  int h,w;
  char c[101][101];
  scanf("%d %d",&h,&w);
  while(h != 0 && w != 0){
    for(int i=0;i<h;i++){
      scanf("%s",c[i]);
    }
    int x=0,y=0;
    while(c[y][x] != '.'){
      
      if(c[y][x] == '0'){
	printf("LOOP\n");
	break;
      }else if(c[y][x] == '>'){
	c[y][x] = '0';
	x++;
      }else if(c[y][x] == '<'){
	c[y][x] = '0';
	x--;
      }else if(c[y][x] == '^'){
	c[y][x] = '0';
	y--;
      }else if(c[y][x] == 'v'){
	c[y][x] = '0';
	y++;
      }
    }
    if(c[y][x] != '0') printf("%d %d\n",x,y);
    scanf("%d %d",&h,&w);
  }
  return (0);
}

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

using namespace std;

int main(){
    int w,h;
    int i,j;
    while(1){
        cin >> w;
        cin >> h;
        if(w == 0 || h == 0) break;
        vector< vector<char> > v(h, vector<char>(w));
        for(j=0;j<h;++j){
            for(i=0;i<w;++i){
                cin >> v[i][j];
            }
        }
        int mi = 0, mj = 0;
        while(true){
            char c = v[mi][mj];
            v[mi][mj] = '#';
            if(c == '>') mi++;
            else if(c == '<') mi--;
            else if(c == '^') mj--;
            else if(c == 'v') mj++;
            else if(c == '#'){
                cout << "LOOP" << endl;
                break;
            } else if( c == '.' ){
                cout << mi << ' ' << mj << endl;
                break;
            }
        }
    }
    return 0;
}

C++: //#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

string s[105];
bool used[105][105];
signed main(void)
{
  while(true) {
    int h, w;
    cin >> h >> w;
    if(!h && !w) break;
    REP(i, h) cin >> s[i];

    int x = 0, y = 0;
    memset(used, false, sizeof(used));
    while(true) {
      if(used[y][x]) {
        cout << "LOOP" << endl;
        break;
      }
      used[y][x] = true;
      if(s[y][x] == '>') {
        x++;
      } else if(s[y][x] == '<') {
        x--;
      } else if(s[y][x] == '^') {
        y--;
      } else if(s[y][x] == 'v') {
        y++;
      } else {
        cout << x << " " << y << endl;
        break;
      }
    }
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(void){
	while(true){
		int x,y;
		int moved = 0;
		bool bLoop = false;
		int h,w;
		char **map;

		cin >> h >> w;
		if( h==0&&w==0 ) break;
		cin.ignore(3,'\n');

		map = new char*[h];
		for(int i = 0; i < h; i++){
			map[i] = new char[w+2];
			cin.getline(map[i], w+2);
		}

		x = 0; y = 0;
		while( true ){
			if( map[y][x] == '.' || bLoop ) break;
			if( moved > h * w + 1 ) bLoop = true;
			switch( map[y][x] ){
				case '>':
					x++;
					break;
				case 'v':
					y++;
					break;
				case '^':
					y--;
					break;
				case '<':
					x--;
					break;
			}
			moved++;
		}
		if( bLoop ) cout << "LOOP\n";
		else cout << x << ' ' << y << '\n';

		for(int i = 0; i < h; i++){
			delete []map[i];
		}
		delete []map;
	}
	return 0;
}

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

int main(void){
	char array[100][100];
	int i,j,w,h;
	while(1){
		cin >> w;
		cin >> h;
		if(w == 0 || h == 0) break;
		for(i=0;i<w;i++) for(j=0;j<h;j++) cin >> array[i][j];		
		i=0;j=0;
		while(1){
			if(array[i][j] == '>'){ array[i][j] = '/'; j++;}
			else if(array[i][j] == '<'){ array[i][j] = '/'; j--;}
			else if(array[i][j] == '^'){ array[i][j] = '/'; i--;}
			else if(array[i][j] == 'v'){ array[i][j] = '/'; i++;}
			else break;
		}
		if(array[i][j] == '/'){ cout << "LOOP" << endl; }
		else { cout << j << " " << i << endl; }
	}
	return 0;
}

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

struct zahyou{
	int x;
	int y;
};

int main(){
	
	int tx,ty,count;
	char map[100][100];
	bool flag;
	struct zahyou now;
	
	
	
	while(cin>>tx>>ty,tx&&ty){
		
		flag=false;
		now.x=0;
		now.y=0;
		memset(map,'\0',sizeof(map));
		
		for(int i=0;i<ty;i++){
			for(int j=0;j<tx;j++){
				cin>>map[i][j];
			}
		}
		
		while(1){

			if(map[now.y][now.x]=='.'){
				cout<<now.x<<" "<<now.y<<endl;
				break;
			}
			else if(map[now.y][now.x]=='1'){
				cout<<"LOOP"<<endl;
				break;
			}

			if(map[now.y][now.x]=='>'){
				map[now.y][now.x]='1';
				now.x++;
			}
			else if(map[now.y][now.x]=='<'){
				map[now.y][now.x]='1';
				now.x--;
			}
			else if(map[now.y][now.x]=='v'){
				map[now.y][now.x]='1';
				now.y++;
			}
			else if(map[now.y][now.x]=='^'){
				map[now.y][now.x]='1';
				now.y--;
			}
		}
	}
}