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 <vector>

using namespace std;

typedef struct{
    int x;
    int y;
}dbint;

dbint move(char c){
    dbint mv;
    switch (c) {
        case '>':
            mv.x=1;
            mv.y=0;
            break;
        case '^':
            mv.x=0;
            mv.y=-1;
            break;
        case '<':
            mv.x=-1;
            mv.y=0;
            break;
        case 'v':
            mv.x=0;
            mv.y=1;
            break;
        default:
            mv.x=10;
            mv.y=10;
            break;
    }
    return mv;
}

int main() {
    int h,w,n=0;
    char c;
    dbint p,mv;
    vector< vector<char> > tiles;
    vector<char> temp;
    while(1){
        cin >> h >> w;
        p.x=0;p.y=0;
        if(h==0&&w==0) break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> c;
                temp.push_back(c);
            }
            tiles.push_back(temp);
            temp.clear();
        }
        while(1){
            mv=move(tiles[p.y][p.x]);
            if(mv.x>1) break;
            p.x+=mv.x;
            p.y+=mv.y;
            n++;
            if(n>h*w+100){
                n=-1;
                break;
            }
        }
        if(n>0) cout << p.x << " " << p.y << endl;
        else    cout << "LOOP" << endl;
        tiles.clear();
    }
    return 0;
}

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

using namespace std;

char board[101 * 101];

int solve(int pos) {
	char c = board[pos];
	board[pos] = '0';
	if (c == '.') return pos;
	else if (c == '0') return -1;
	else if (c == '>') return solve(pos + 1);
	else if (c== '<') return solve(pos - 1);
	else if (c == '^') return solve(pos - 101);
	else return solve(pos + 101);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;

	while (cin >> H >> W, H) {
		for(int y = 0; y < H; y++)
			for(int x = 0; x < W; x++)
				cin >> board[y*101 + x];
		int ret = solve(0);
		if (ret == -1)
			cout << "LOOP" << endl;
		else
			cout << ret % 101 << " " << ret / 101 << endl;
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int w,h;
  string a[102];
  while(cin>>w>>h,w){
    for(int i=0;i<102;i++){
      a[i]="";
    }
    for(int i=0;i<w;i++){
      cin>>a[i];
    }
    int x=0,y=0;
    while(true){
      if(a[x][y]=='.'){cout<<y<<' '<<x<<endl;break;}
      else  if(a[x][y]=='o'){cout<<"LOOP"<<endl; break;}
      else if(a[x][y]=='>'){a[x][y]='o'; y++;}
      else if(a[x][y]=='<'){a[x][y]='o'; y--;}
      else if(a[x][y]=='^'){a[x][y]='o'; x--;}
    else if(a[x][y]=='v'){a[x][y]='o'; x++;}
    }
  }
}

C++: #include <iostream>

int main(int argc, char **argv)
{
	int h, w;
	int x = 0, y = 0;
	char tiles[100][100];
	bool throughed[100][100] = {};
	bool loop = false;
	bool end = false;
	while(std::cin >> h >> w, h+w != 0){
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				std::cin >> tiles[j][i];
			}
		}
		while(true){
			if(throughed[x][y]){
				loop = true;
				break;
			}
			throughed[x][y] = true;
			switch(tiles[x][y]){
				case '.':
					end = true;
					break;
				case '^':
					y--;
					break;
				case 'v':
					y++;
					break;
				case '<':
					x--;
					break;
				case '>':
					x++;
					break;
			}
			if(end){
				break;
			}
		}
		if(loop){
			std::cout << "LOOP" << std::endl;
		}else{
			std::cout << x << " " << y << std::endl;
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
char s[101][102];

int n,m;
void solve()
{
	for(int i= 0 ; i < n; i++) cin>>s[i];
	int x = 0,y = 0;
	while(s[y][x] != '.'){
		char c = s[y][x];
		s[y][x] = '#';
		switch(c){
		case '#':
			puts("LOOP");
			return;
		case '>':
			x++;
			break;
		case '<':
			x--;
			break;
		case 'v':
			y++;
			break;
		case '^':
			y--;
			break;
		}
	}
	printf("%d %d\n",x,y);
}

int main(){
	while(cin>>n>>m,(n||m)){
		solve();
	}
    return 0;
}

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

int m,n,w,h;
char b[102][102];
bool v[102][102];

void dfs(int y,int x){
    if(v[y][x]){
        cout<<"LOOP"<<endl;
        return;
    }
    v[y][x]=1;
    if(b[y][x]=='>'){
        dfs(y,x+1);
        return;
    }
    if(b[y][x]=='v'){
        dfs(y+1,x);
        return;
    }
    if(b[y][x]=='<'){
        dfs(y,x-1);return;
    }
    if(b[y][x]=='^'){
        dfs(y-1,x);return;
    }
    cout<<x<<" "<<y<<endl;
}

int main(){
    while(cin>>h>>w,w||h){
        for(int i=0;i<h;i++)
            cin>>b[i];
        memset(v,0,sizeof(v));
        dfs(0,0);
    }
}

C++: /*
	0104:Magical Tiles
*/
#include	<iostream>
#include	<vector>
#include	<cstdio>

using namespace std;

int main(void) {
	int H, W;
	while(1) {
		cin >> W >> H;
		if(H == 0 && W == 0) {
			break;
		}
		vector< vector<char> > tiles;
		vector< vector<int> > status;
		
		tiles.resize(W + 1);
		status.resize(W + 1);
		for(int i = 0; i < (int)tiles.size(); i++) {
			tiles[i].resize(H + 1);
			status[i].resize(H + 1);
		}
		
		for(int i = 0; i < (int)tiles.size() - 1; i++) {
			for(int j = 0; j < (int)tiles[i].size(); j++) {
				scanf("%c", &tiles[i][j]);
			}
		}
		
		for(int i = 0; i < (int)status.size(); i++) {
			for(int j = 0; j < (int)status[i].size(); i++) {
				status[i][j] = 0;
			}
		}
		
		int a = 0, b = 0;
		while(1) {
			if(tiles[a][b] == '.') {
				cout << b << ' ' << a << endl;
				break;
			}
			else if(status[a][b] == 1) {
				cout << "LOOP" << endl;
				break;
			}
			else {
				status[a][b] = 1;
				
				if(tiles[a][b] == '<') {
					//cout << "MOVE:" << '<' << endl;
					b--;
				}
				else if(tiles[a][b] == '>') {
					//cout << "MOVE:" << '>' << endl;
					b++;
				}
				else if(tiles[a][b] == '^') {
					//cout << "MOVE:" << '^' << endl;
					a--;
				}
				else if(tiles[a][b] == 'v') {
					//cout << "MOVE:" << 'v' << endl;
					a++;
				}
			}
		}
	}
	
	return 0;
}