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>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  while(1){
    int h,w;
    cin>>h>>w;
    if(h==0 && w==0)break;
    char v[100][100];
    rep(i,h)scanf("\n%s",v[i]);
    int used[100][100]={};
    i=0;j=0;
    bool ans=true;
    while(1){
      if(used[i][j]){
        ans=false;
        break;
      }
      used[i][j]++;
      if(v[i][j]=='>')j++;
      else if(v[i][j]=='<')j--;
      else if(v[i][j]=='^')i--;
      else if(v[i][j]=='v')i++;
      else break;
    }
    if(ans)cout<<j<<" "<<i<<endl;
    else cout<<"LOOP"<<endl;
  }
}

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 <iostream>
using namespace std;

#define max 100
char map[100][100];
bool visited[100][100];

int main(void){

	while( 1 ) {
		int pos[] = {0, 0};
		int w, h;
		cin >> h >> w;
		if( !(w|h) ) break;

		for(int i = 0; i < max * max; i++)
			visited[ i / max ][ i % max ] = false;
		for(int i = 0; i < h; i++)
			cin >> map[i];

		while( !(visited[ pos[0] ][ pos[1] ] == true || map[ pos[0] ][ pos[1] ] == '.') ) {
			visited[ pos[0] ][ pos[1] ] = true;
			switch( map[ pos[0] ][ pos[1] ] ) {
				case '>':
					pos[1] ++;
					break;
				case '<':
					pos[1] --;
					break;
				case '^':
					pos[0] --;
					break;
				case 'v':
					pos[0] ++;
					break;
			}
		}

		if( visited[ pos[0] ][ pos[1] ] == true )
			cout << "LOOP" << endl;
		else
			cout << pos[1] << " " << pos[0] << endl;

	}

	return 0;
}

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

int x, y, d, HW, H, W;
string input[10];
bool orLoop[10][10];

bool loop(int a, int b){
	if(orLoop[b][a]){
		return true;
	}
	char i = input[b][a];
	if(i=='>'){
		orLoop[b][a] = true;
		loop(a + 1, b);
	}
	else if(i=='v'){
		orLoop[b][a] = true;
		loop(a, b + 1);
	}
	else if(i=='<'){
		orLoop[b][a] = true;
		loop(a - 1, b);
	}
	else if(i=='^'){
		orLoop[b][a] = true;
		loop(a, b - 1);
	}
	else{
		x = a;
		y = b;
		return false;
	}
}

int main(){
	while(cin >> H >> W){
		if (H == 0 && W == 0) { break; }
		else { HW = H*W + 2; }

		for (int i = 0; i < 10;i++){
			for (int j = 0; j < 10;j++){
				orLoop[i][j] = false;
			}
		}
			for (int i = 0; i < H; i++)
			{
				cin >> input[i];
			}
		if(loop(0, 0)){
			cout << "LOOP" << endl;
		}
		else{
			cout << x << " " << y << endl;
		}
	}
	return 0;
}

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

using namespace std;

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

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;
	for(d = 0;d < 4;d++){
		if(tmp == dir[d]){
			break;
		}
	}
	return rec(y + dy[d],x + dx[d]);
}


int main(void){
	int h, w;
	while(true){
		scanf("%d%d",&h,&w);
		getchar();
		if(h == 0 && w == 0){
			break;
		}
		for(int i = 0;i < h;i++){
			scanf("%s",&mp[i]);
		}
		printf("%s\n",rec(0,0));
	}
	return 0;
}

C++: #include <iostream>

enum struct Panel { none, up, down, right, left };

int main() {
    int h, w;
    while (std::cin >> h >> w && h != 0 && w != 0) {
        std::cin.ignore();

        auto room = new std::pair<Panel, bool>[h * w]();
        std::string s;
        for (int i = 0; i < h; i++) {
            std::getline(std::cin, s);
            for (int j = 0; j < w; j++) {
                switch (s[j]) {
                    case '.': room[i * w + j].first = Panel::none; break;
                    case '^': room[i * w + j].first = Panel::up; break;
                    case 'v': room[i * w + j].first = Panel::down; break;
                    case '>': room[i * w + j].first = Panel::right; break;
                    case '<': room[i * w + j].first = Panel::left; break;
                    default: return EXIT_FAILURE;
                }
            }
        }

        int x = 0, y = 0;
        [&]() {
            while (true) {
                if (room[y * w + x].second) {
                    std::cout << "LOOP";
                    break;
                }
                room[y * w + x].second = true;
                switch (room[y * w + x].first) {
                    case Panel::up: y--; break;
                    case Panel::down: y++; break;
                    case Panel::right: x++; break;
                    case Panel::left: x--; break;
                    case Panel::none: std::cout << x << ' ' << y; return;
                }
            }
        }();
        std::cout << std::endl;
    }
}

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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

char grid[110][110];

int main(){
    int w,h;
    while(cin>>h>>w, h||w){
        bool vis[110][110]={};
        rep(y,h) cin>>grid[y];
        int px=0, py=0;
        bool loop=false;
        while(1){
            if(vis[py][px]){
                loop=true; break;
            }
            vis[py][px]=true;
            char c=grid[py][px];
            if(c=='.') break;
            else if(c=='>') px++;
            else if(c=='^') py--;
            else if(c=='<') px--;
            else if(c=='v') py++;
        }
        if(loop) cout<<"LOOP"<<endl;
        else cout<<px<<" "<<py<<endl;
    }

}