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++: #include<iostream>

using namespace std;

int main()
{
	int W, H;
	char field[100][100];
	bool passed[100][100];
	while(1)
	{
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		for(int y = 0;y < H;y++)
		{
			for(int x = 0;x < W;x++)
			{
				cin >> field[y][x];
				passed[y][x] = false;
			}
		}
		
		int cx = 0, cy = 0;
		bool loop = false;
		while(1)
		{
			int dx = 0, dy = 0;
			char cell = field[cy][cx];
			if(passed[cy][cx])
			{
				loop = true;
				break;
			}
			else if(cell == '>') dx++;
			else if(cell == '<') dx--;
			else if(cell == '^') dy--;
			else if(cell == 'v') dy++;
			else if(cell == '.') break;
			passed[cy][cx] = true;
			cx += dx;
			cy += dy;
		}
		if(loop) cout << "LOOP" << endl;
		else cout << cx << ' ' << cy << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
int main() {
	int h, w;
	while (cin >> h >> w, h, w) {
		char map[114][514];
		bool b[114][514] = {};
		rep(i, h)rep(j, w)cin >> map[i][j];
		int x = 1, y = 1;
		rep(i, 10010) {
			if (b[x][y]) { cout << "LOOP\n"; goto end; }
			b[x][y] = true;
			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 {
				cout << --y << ' ' << --x << endl;
				goto end;
			}
		}
	end:;
	}
}

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