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>

using namespace std;
int H, W;
int x = 0, y = 0;
int rog[100][100];
bool check(){
	if (rog[x][y] == 0){
		cout << "LOOP" << endl;
		return true;
	}
	else{
		return false;
	}
}
int main(){
	char map[100][100];

	while (cin >> H >> W,W+H){

		int x = 0, y = 0;
		map[100][100] = {};
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> map[i][j];
				rog[i][j] = 1;
			}
		}
		while (1){
			if (map[x][y] == '>'){
				x++;
				if (check())break; 
			}
			else if(map[x][y]=='v'){
				y++;
				if (check()) break; 
			}
			else if (map[x][y] == '<'){
				x--;
				if (check()) break; 
			}
			else if (map[x][y] == '^'){
				y--;
				if (check())break; 
			}
			else {
				cout << x << " " << y << endl;
				break;
			}
			
			rog[x][y] = 0;

		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int h,w;
  while(cin>>h>>w,h+w) {
    char ba[w][h];
    REP(y,h) {
      REP(x,w) {
        cin >> ba[x][y];
      }
    }
    int x = 0, y = 0;
    int dx[] = {0,1,0,-1};
    int dy[] = {-1,0,1,0};
    char aa[] = {'^','>','v','<'};
    map<char,int> hoge;
    REP(i,4)
      hoge[aa[i]] = i;
    int f[w][h];
    memset(f,0,sizeof(f));
    while(true) {
      if (f[x][y]) break;
      if (ba[x][y] == '.') break;

      f[x][y]=1;
      x += dx[hoge[ba[x][y]]];
      y += dy[hoge[ba[x][y]]];
    }
    if (f[x][y]) cout << "LOOP" << endl;
    else cout << x << " " << y << endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;

int main() {

  int w, h;
  while( cin >> h >> w, w+h ) {
    char room[10][10];
    bool flag[10][10];
    int now_x = 0, now_y = 0;

    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) {
	cin >> room[i][j];
	flag[i][j] = false;
      }
    }

    while(1) {
      if( flag[now_y][now_x] || room[now_y][now_x] == '.' ) break;
      char c = room[now_y][now_x];
      flag[now_y][now_x] = true;
     

      if( c == '>' ) {
	while( room[now_y][now_x] == c ) {
	  flag[now_y][now_x] = true;
	  now_x++;
	}
      }
      if( c == '<' ) {
	while( room[now_y][now_x] == c ) {
	  flag[now_y][now_x] = true;
	  now_x--;
	}
      }
      if( c == 'v' ) {
	while( room[now_y][now_x] == c ) {
	  flag[now_y][now_x] = true;
	  now_y++;
	}
      }
      if( c == '^' ) {
	while( room[now_y][now_x] == c ) {
	  flag[now_y][now_x] = true;
	  now_y--;
	}
      }
    }

    if( room[now_y][now_x] != '.' ) cout << "LOOP" << endl;
    else cout << now_x << " " << now_y << endl;
  }
}

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

int main(){
  while(1){
    int h, w;
    cin >> h >> w;
    if(h==0 && w==0) break;
    getchar();

    bool p[N][N];
    char data[N][N];

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> data[i][j];
	p[i][j]=false;
      }
    }

    int x=0, y=0;
    while(1){
      if(p[y][x]){
	cout << "LOOP" << endl;
	return 0;
      }
      p[y][x]=true;
      if(data[y][x]=='>'){
	x++;
      }
      else if(data[y][x]=='<'){
	x--;
      }
      else if(data[y][x]=='^'){
	y--;
      }
      else if(data[y][x]=='v'){
	y++;
      }
      else if(data[y][x]=='.'){
	break;
      }
    }
    cout << x << ' ' << y << endl;
  }
  return 0;
}

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

using namespace std;
 
#define RIGHT '>'
#define LEFT '<'
#define TOP '^'
#define UNDER 'v'
#define LOOP 'l'
#define END '.'
#define MAX 101
 
void dfs(char mp[MAX][MAX], int i, int j)
{
    if (mp[i][j] == END) {
        printf("%d %d\n", j, i);
        return;
    }
    if (mp[i][j] == LOOP) {
        printf("LOOP\n");
        return;
    }
     
    if (mp[i][j] == RIGHT) {
        mp[i][j] = LOOP;
        dfs(mp, i, j+1);
    } else if (mp[i][j] == LEFT) {
        mp[i][j] = LOOP;
        dfs(mp, i, j-1);
    } else if (mp[i][j] == TOP) {
        mp[i][j] = LOOP;
        dfs(mp, i-1, j);
    } else {
        mp[i][j] = LOOP;
        dfs(mp, i+1, j);
    }
}
 
int main()
{
    char mp[MAX][MAX];
    int n, m;
     
    while (cin >> n >> m, (n | m)) {
        for (int i = 0; i < n; i++) {
            cin >> mp[i];
        }
        dfs(mp, 0, 0);
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include<iomanip>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) (s).begin(),(s).end()
#define ITE(c) typeof((c).begin())

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))

using namespace std;

int  vis[128][128]; 
char dat[128][128];


int main(){
	int w, h;
	while(cin>>h>>w,w||h){
		rep(i,128){
			rep(j,128){
				vis[j][i]=0;
				dat[j][i]=0;
			}
		}
		
		rep(i,h){
			rep(j,w){
				cin>>dat[j][i];
			}
		}
		int px=0, py=0;
		while(dat[px][py]!='.'){
			if(vis[px][py]) break;
			vis[px][py]=1;
			switch(dat[px][py]){
				case '>':px++;break;
				case '<':px--;break;
				case '^':py--;break;
				case 'v':py++;break;
			}
		}
		if(vis[px][py]){
			cout<<"LOOP"<<endl;
		}else{
			cout<<px<<" "<<py<<endl;
		}
	}
	return 0;
}

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

int main(){
    char mymap[101][101];
    int x, y;
    int px = 0; int py = 0; int step = 0;
    while (1){
	cin >> x >> y;
	if (!x && !y) break;
	for (int i = 0; i < x; i++){
	    for (int j = 0; j < y; j++){
		cin >> mymap[i][j];
	    }
	}
/*	for (int i = 0; i < x; i++){
	for (int j = 0; j < y; j++){
	cout << mymap[i][j];
	}
	cout << endl;
	}
*/
	step = px = py = 0;
	while (mymap[px][py] != '.' && step <= x*y){
	    switch (mymap[px][py]){
		case '>':
		    py++; break;
		case 'v':
		    px++; break;
		case '<':
		    py--; break;
		case '^':
		    px--; break;
		default: break;
	    }
	    step++;
	}
	if (step <= x*y)
	    cout << py << " " << px << endl;
	else
	    cout << "LOOP" << endl;
    }
}