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;

char c[101][101] = { 0 };
int x, y;

void move_tile() {
	if (x > 10 || y > 10) return;
	if (c[y][x] == '^') {
		c[y][x] = 'l';
		y = y - 1;
		move_tile();
	}else if(c[y][x]=='v'){
		c[y][x] = 'l';
		y = y + 1;
		move_tile();
	}else if (c[y][x] == '<') {
		c[y][x] = 'l';
		x = x - 1;
		move_tile();
	}
	else if (c[y][x] == '>') {
		c[y][x] = 'l';
		x = x + 1;
		move_tile();
	}
	else {
		return;
	}

}

int main(void) {
	while (1) {
		int h, w;
		cin >> h >> w;
		if (h == 0)return 0;
		for (int i = 0; i <h ; i++) {
			for (int j = 0; j < w; j++) {
				cin >> c[i][j];
			}
		}

		x = y = 0;
		move_tile();

		if (c[y][x] == 'l') {
			cout << "LOOP" << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}

}

C++: #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

main(){
	int n=1,m=1,b[100],c[100];
	
	char a[100][100];
	
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0) break;
		for(int i=0 ; i<n ; i++){
			scanf("%s",a[i]);
		}
		
		int i=0,j=0,o=0,u=0;
		
		while(1){
			if(a[i][j]=='>') j++;
			if(a[i][j]=='<') j--;
			if(a[i][j]=='v') i++;
			if(a[i][j]=='^') i--;
			if(a[i][j]=='.'){
				u=0; break;
			}
			b[o]=i;
			c[o]=j;
			for(int p=0; p<o ; p++){
				if(b[p]==i && c[p]==j){
					 u++;
				}
			}
			o++;
			if(u>0) break;
		}
		
		if(u==1) printf("LOOP\n");
			else printf("%d %d\n",j,i);
		u=0;
	}

}

C++: #include <iostream>
#include <cstdio>
using namespace std;
char a[100][101];
int h,w;
 
int main() {
        while(1){
     cin>>h>>w;
     bool flag=true;
     if(!h&&!w)break;
     for(int i=0;i<h;i++){
         scanf("%s",a[i]);
     }
     int x=0,y=0;
     for(int i=0;i<h*w+1;i++){
         if(a[y][x]=='>')x++;
         if(a[y][x]=='<')x--;
         if(a[y][x]=='^')y--;
         if(a[y][x]=='v')y++;
         if(i==h*w&&a[y][x]!='.')flag=false;
     }
     if(flag)cout<<x<<" "<<y<<endl;
     else cout<<"LOOP"<<endl;
        }
        return 0;
}

C++: #include <stdio.h>
struct point{
    int x;
    int y;
    void init(){
        x=0;
        y=0;
    };
};
int main(){
    int h,w;
    point now;
    char a[100][100];
    bool went[100][100];
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0)return 0;
        for(int i=0;i<h;i++){
            scanf("%s",a[i]);
            for(int j=0;j<w;j++)went[i][j]=false;
        }
        now.init();
        while(a[now.x][now.y]!='.'){
            if(went[now.x][now.y]){
                printf("LOOP\n");
                break;
            }
            went[now.x][now.y]=true;
            if(a[now.x][now.y]=='v')now.x++;
            else if(a[now.x][now.y]=='^')now.x--;
            else if(a[now.x][now.y]=='<')now.y--;
            else if(a[now.x][now.y]=='>')now.y++;
        }
        if(a[now.x][now.y]=='.')printf("%d %d\n",now.y,now.x);
    }
}

C++: #include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
	for(int w,h;cin>>h>>w;){
		if(w==0&&h==0)break;
		vector<string> v;
		set<int> visited;
		for(int i=0;i<h;++i){
			string s;
			cin>>s;
			v.push_back(s);
		}
		for(int x=0,y=0;;){
			if(visited.find(y*w+x)!=visited.end()){
				cout<<"LOOP\n";
				break;
			}
			visited.insert(y*w+x);
			if(v[y][x]=='.'){
				cout<<x<<" "<<y<<"\n";
				break;
			}else if(v[y][x]=='>')++x;
			else if(v[y][x]=='<')--x;
			else if(v[y][x]=='v')++y;
			else if(v[y][x]=='^')--y;
		}
	}
}

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 ) {
	  now_x++;
	}
      }
      if( c == '<' ) {
	while( room[now_y][now_x] == c ) {
	  now_x--;
	}
      }
      if( c == 'v' ) {
	while( room[now_y][now_x] == c ) {
	  now_y++;
	}
      }
      if( c == '^' ) {
	while( room[now_y][now_x] == c ) {
	  now_y--;
	}
      }
    }

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

C++: #include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define X first
#define Y second

using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const string p = "<v>^";
const int dx[4] = {-1,  0,  1,  0};
const int dy[4] = { 0,  1,  0, -1};

char m[101][101];

int main(void){
    map<char, pii> dir;
    rep(i, 4) dir[p.at(i)] = mp(dx[i], dy[i]);

    for(int h, w; cin >> h >> w, h;){
        rep(y, h) cin >> m[y];

        pii curP = mp(0, 0);
        char cur; int cnt = 0;
        while((cur = m[curP.Y][curP.X]) != '.'){
            curP.X += dir[cur].X;
            curP.Y += dir[cur].Y;

            if(w * h < ++cnt){
                cout << "LOOP" << endl;
                cnt = -1;
                break;
            }
        }
        if(~cnt) cout << curP.X << ' ' << curP.Y << endl;
    }
 
    return 0;
}

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

using namespace std;

int main(){
	int H,W;
	while(cin>>H>>W,H){
		vector<string> vstr(H);
		vector<bool> memo(H*W,false);
		for(int i=0;i<H;i++){
			string str;
			cin>>str;
			vstr[i]=str;
		}
		int x=0,y=0;
		bool flag=false;
		while(!flag){
			memo[x+y*W]=true;
			switch(vstr[y][x]){
			case '>':
				x++;
				break;
			case '<':
				x--;
				break;
			case '^':
				y--;
				break;
			case 'v':
				y++;
				break;
			case '.':
				flag=true;
				break;
			}
			if(!flag){
				if(memo[y*W+x]){
					break;
				}
			}
		}
		if(flag){
			cout<<x<<" "<<y<<endl;
		}
		else{
			cout<<"LOOP"<<endl;
		}
	}

	return 0;
}

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

using namespace std;

string mp[100];
string dir = "^>v<";
const int dy[4] = {-1,0,1,0}, dx[4] = {0,1,0,-1};

char *rec(int y,int x){
	char tmp = mp[y][x];
	if(tmp == '.'){
		char ret[256];
		sprintf(ret,"%d %d",x,y);
		return ret;
	}else if(tmp == 't'){
		char ret[] = "LOOP";
		return ret;
	}
	mp[y][x] = 't';
	int d = dir.find(tmp);
	return rec(y + dy[d],x + dx[d]);
}


int main(void){
	int h, w;
	while(true){
		cin >> h >> w;
		cin.get();
		if(h == 0 && w == 0){
			break;
		}
		for(int i = 0;i < h;i++){
			getline(cin,mp[i]);
		}
		cout << rec(0,0) << endl;
	}
	return 0;
}