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

int w, h;
char map[102][102];
bool closed[102][102];
void rec(int x, int y){
  if(closed[y][x]){
    cout << "LOOP" << endl;
    return;
  }
  closed[y][x] = true;
  if(map[y][x] == '>')rec(x+1,y);
  else if(map[y][x] == 'v')rec(x, y+1);
  else if(map[y][x] == '<')rec(x-1,y);
  else if(map[y][x] == '^')rec(x,y-1);
  else {
    cout << x << " " << y << endl;
  }
}
void solve(){
  rec(0,0);
}
int main(){
  while(cin >> h >> w, w||h){
    memset(map, 0, sizeof(map));
    for(int i = 0; i < h; i++)cin >> map[i];
    solve();
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <time.h>
#include<string>
using namespace std;
int main(){
	char tile[101][101];
	int dp[101][101]={0};
	bool finished=false;
	int x,y;
	while(1){
		cin>>y>>x;
		memset(dp,0,sizeof(dp));
		finished=false;
		if(y==0 && x==0){
			break;
		}
		for(int i=0;i<y;i++){
			for(int j=0;j<x;j++){
				cin>>tile[i][j];
			}
		}int i=0,j=0;
		while(1){
			switch(tile[i][j]){
			case '>': j++ ;dp[i][j]++;break;
			case '<': j--;dp[i][j]++;break;
			case '^': i--;dp[i][j]++;break;
			case 'v': i++;dp[i][j]++;break;
			case '.': cout<<j<<" "<<i<<endl;finished=true; break;
			}
			if(finished==true){
				break;
			}
			if(dp[i][j]==2){
				cout<<"LOOP"<<endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int w,h;
	int dx[128]={0};
	int dy[128]={0};
	dx['<'] = -1;
	dx['>'] = 1;
	dy['^'] = -1;
	dy['v'] = 1;
	while(cin >> h >> w , w){
		char data[128][128]={0};
		rep(i,h)rep(j,w)cin >> data[i][j];
		int x = 0 , y = 0 , f = 0;
		while(data[y][x]!='.'){
			char c = data[y][x];
			if(c == '-'){f = 1 ; break;}
			else data[y][x] = '-';
			x += dx[c] , y += dy[c];
		}
		if(f)cout << "LOOP" << endl;
		else cout << x << " " << y << endl;
	}
}

C++: #include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
vector<string> field;
int y,x;
bool solve(void){
  for(;;){
    if(field[y][x]=='l') return false;
    if(field[y][x]=='.') return true;
    if(field[y][x]=='^') field[y--][x]='l';
    if(field[y][x]=='v') field[y++][x]='l';
    if(field[y][x]=='<') field[y][x--]='l';
    if(field[y][x]=='>') field[y][x++]='l';
  }
}   
int main(void)
{
  for(;;){
    int h,w;
    cin >> h >> w;
    if(!h&&!w) return 0;
    y=0; x=0;
    field.resize(h);
    REP(i,h) cin >> field[i];
    if(solve()) cout << x << ' ' << y << endl;
    else cout << "LOOP" << endl;
  }
}

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

using namespace std;

int main(){
	int w, h;
	char room[100][100];
	vector<pair<int, int>> visited;
	if(cin >> h >> w, h || w){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> room[i][j];
			}
		}
		visited.push_back(pair<int, int>(0, 0));
		int flag = 1;
		while (flag){
			pair<int, int> tmp;
			switch (room[visited.back().first][visited.back().second])
			{
			case '>':
				tmp.first = visited.back().first;
				tmp.second = visited.back().second + 1;
				visited.push_back(tmp);
				break;
			case '<':
				tmp.first = visited.back().first;
				tmp.second = visited.back().second - 1;
				visited.push_back(tmp);
				break;
			case '^':
				tmp.first = visited.back().first - 1;
				tmp.second = visited.back().second;
				visited.push_back(tmp);
				break;
			case 'v':
				tmp.first = visited.back().first + 1;
				tmp.second = visited.back().second;
				visited.push_back(tmp);
				break;
			case '.':
				cout << visited.back().second << ' ' << visited.back().first << endl;
				flag = 0;
				break;
			}
			for (int i = visited.size() - 2; i >= 0; i--){
				if (visited[i] == tmp){
					cout << "LOOP" << endl;
					flag = 0;
					break;
				}
			}
		}
	}
	return 0;
}

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

int main()
{
    int x,y;
    while(cin>>x>>y,x||y){
        string map[x];
        for(int i=0;i<x;i++){
            cin>>map[i];
        }
        int X=0,Y=0;
        bool end=false;
        int loopCount=1;
        while(true){
            switch(map[Y][X]){
                case '^' :
                    Y--;
                    break;
                case '>' :
                    X++;
                    break;
                case 'v' :
                    Y++;
                    break;
                case '<' :
                    X--;
                    break;
                case '.' :
                    end=true;
                    break;
            }
            if(end){
                cout<<X<<' '<<Y<<endl;
                break;
            }
            if(loopCount>x*y){
                cout<<"LOOP"<<endl;
                break;
            }
            loopCount++;
        }
    }
}

C++: #include <iostream>
#include <algorithm>
#define MH 100
#define MW 100
using namespace std;
char f[MH][MW];
bool u[MH][MW];

void move(int x, int y) {
	if (u[y][x] == true) cout << "LOOP" << endl;
	else {
		u[y][x] = true;
		if (f[y][x] == '.') cout << x << " " << y << endl;
		else {
			if (f[y][x] == '<') move(x - 1, y);
			if (f[y][x] == '^') move(x, y - 1);
			if (f[y][x] == '>') move(x + 1, y);
			if (f[y][x] == 'v') move(x, y + 1);
		}
	}
	return;
}

int main() {
	int h, w;

	while (cin >> h >> w, !(h == 0 && w == 0)) {
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				cin >> f[i][j];
			}
		}
		fill(u[0], u[MH], false);
		move(0, 0);
	}
	return 0;
}

C++: #include <stdio.h>
#define North 0
#define East 1
#define West 2
#define South 3
#define No 4

int src[5][2]={{-1,0},{0,1},{0,-1},{1,0},{0,0}};

class Pair{
public:
	Pair(){x=y=0;}
	void move(int t){
		x+=src[t][0];
		y+=src[t][1];
	}
	int x,y;
};

int main(){
	while(1){
		int h,w;
		bool stop=false;
		Pair pos;
		char c[101][101];
		scanf("%d%d",&h,&w);
		if(!h&&!w) break;
		for(int i=0;i<h;i++) scanf("%s",c[i]);
		while(!stop){
			Pair tmp=pos;
			switch(c[pos.x][pos.y]){
			case '^':
				pos.move(North);
				break;
			case '>':
				pos.move(East);
				break;
			case '<':
				pos.move(West);
				break;
			case 'v':
				pos.move(South);
				break;
			case '.':
				stop=true;
				printf("%d %d\n",pos.y,pos.x);
				break;
			case 0:
				stop=true;
				printf("LOOP\n");
			}
			c[tmp.x][tmp.y]=0;
		}
	}
	return 0;
}

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

using namespace std;

int main(void){
	int w,h;
	while(cin>>>h>>w,h){
		string f[h];
		for(int i=0,i<h;i++){
			cin>>f[i];
		}	
		int x,y;
		x=y=0;
		bool used[h][w];
		memset(used,0,sizeof(used));
		while(true){
			if(used[y][x]){
				cout<<"LOOP"<<endl;
				break;
			}
			if(f[y][x]=='.'){
				cout<<x<<" "<<y<<endl;
				break;
			}
			used[y][x]=true;
		}
	
		switch(f[y][x]){
			case '>': x+=1; break;
			case '<': x-=1; break;
			case '^': y-=1; break;
			case 'v': y+=1; break;
		}
	}
}