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 <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	int w,h;
	while(cin>>h>>w&&!(w==0&&h==0)){
		vector<string> field;
		string str;
		for(int i = 0; i < h; i++){
			cin>>str;
			field.push_back(str);
		}
		bool isPassed[200][200];
		memset(isPassed,0,sizeof(isPassed));
		int sy,sx;
		sy=sx=0;
		bool f=true;
		while(1){
			if(isPassed[sy][sx]){
				f=false;
				break;
			}
			isPassed[sy][sx]=true;
			if(field[sy][sx]=='>'){
				sx++;
			}
			else if(field[sy][sx]=='<'){
				sx--;
			}
			else if(field[sy][sx]=='v'){
				sy++;
			}
			else if(field[sy][sx]=='^'){
				sy--;
			}
			else
				break;
		}
		if(!f){
			cout<<"LOOP"<<endl;
		}
		else
			cout<<sx<<" "<<sy<<endl;
	}

	return 0;
}

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

using namespace std;

int main(){

	int w,h;
	while(cin>>w>>h&&w!=0&&h!=0){
		vector<string> field;
		string str;
		for(int i = 0; i < h; i++){
			cin>>str;
			field.push_back(str);
		}
		bool isPassed[200][200];
		memset(isPassed,0,sizeof(isPassed));
		int sy,sx;
		sy=sx=0;
		bool f=true;
		while(1){
			if(isPassed[sy][sx]){
				f=false;
				break;
			}
			isPassed[sy][sx]=true;
			if(field[sy][sx]=='>'){
				sx++;
			}
			else if(field[sy][sx]=='<'){
				sx--;
			}
			else if(field[sy][sx]=='v'){
				sy++;
			}
			else if(field[sy][sx]=='^'){
				sy--;
			}
			else
				break;
		}
		if(!f){
			cout<<"LOOP"<<endl;
		}
		else
			cout<<sx<<" "<<sy<<endl;
	}

	return 0;
}

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

int main(){
	int w,h,x,y;
	char tile[100][100];
	bool use[100][100];
	bool flg;
	
	while(1){
	 cin>>w>>h;
	 if(w==0 && h==0){break;}
	 for(y=0;y<h;y++){
	  for(x=0;x<w;x++){
	   cin>>tile[x][y];
	   use[x][y]=false;
	  }
	 }
	 
	 x=0;y=0;flg=true;
	 do{
	  if(use[x][y]){cout<<"LOOP"<<endl;break;}
	  use[x][y]=true;
	  switch(tile[x][y]){
		case '.':
		flg=false;
		cout<<x<<" "<<y<<endl;
		break;

		case '>':
		x+=1;
		break;

		case '<':
		x-=1;
		break;

		case '^':
		y-=1;
		break;

		case 'v':
		y+=1;
		break;
	  }
	 }while(flg);
	}
}

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",rec(0,0));
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdio>
#define MAX_N 105

using namespace std;
int n,h,w;
int area[MAX_N][MAX_N];
string s[MAX_N];

void move(int h,int w){
	if(area[h][w]==1){
		cout << "LOOP" << endl;
		return;
	}
	area[h][w]=1;
	
	switch(s[h][w]){

		case'>':
		move(h,w+1);
		return;
		break;

		case'<':
		move(h,w-1);
		return;
		break;

		case'v':
		move(h+1,w);
		return;
		break;

		case'^':
		move(h-1,w);
		return;
		break;

		case'.':
		cout << w<< " "<<h<<endl;
		return;
		break;
	}
	return;
}

int main(){
	while(1){
		cin >> h >> w;
		if(h==0&&w==0)break;

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				area[i][j]=0;
			}
		}

		for(int i=0;i<h;i++){
			cin >> s[i];
		}
		move(0,0);

	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
const int N=101;
string G[N];
bitset<N> vis[N];
int n,m;
signed main(void){
	ios::sync_with_stdio(false);
	while(cin>>n>>m&&n&&m){
		//getchar();
		for(int i=0;i<n;i++)
				cin>>G[i];
		int x=0,y=0;
		for(int i=0;i<n;i++)
			vis[i].reset();
		while(true){
			if(vis[x][y]){
				cout<<"LOOP"<<endl;	
				break;
			}
			else if(G[x][y]=='.'){
				cout<<y<<" "<<x<<endl;
				break;	
			}
			vis[x][y]=true;
			switch(G[x][y]){
				case('>'):y++;break;
				case('<'):y--;break;
				case('^'):x--;break;
				case('v'):x++;break;
			}
		}
	}
}

C++: #include <iostream>
using namespace std;
int main(){
    char a[100][100];
    int h,w,n=0;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    h=0;
    w=0;
    while(true){
        n+=1;
        if(a[w][h]=='.'){
            break;
        }
        if(a[h][w]=='>'){
            w+=1;
        }
        if(a[h][w]=='<'){
            w-=1;
        }
        if(a[h][w]=='^'){
            h-=1;
        }
        if(a[h][w]=='v'){
            h+=1;
        }
        if(n==10001){
            break;
        }
    }
    if(n==10001){
        cout<<"LOOP"<<endl;
    }
    else{
        cout<<w<<" "<<h<<endl;
    }
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n,m;
    bool loop;
    int a,b;

    while(cin >> a >> b, b){
        char map[100][100];
        n = m = 0;
        loop = true;
        rep(i,a){
            rep(j,b){
                cin >> map[i][j];
            }
        }
        for(int k = 0; k < a * b; k++){
            if(map[n][m] == '>')
                m++;
            else if(map[n][m] == '<')
                m--;
            else if(map[n][m] == 'v')
                n++;
            else if(map[n][m] == '^')
                n--;
            else
                loop = false;
        }
        if(loop == false)
            cout << m << " " << n << endl;
        else
            cout << "LOOP" << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main() {
    int h, w;
    char c;
    char map_[101][101];
    while (true) {
        cin >> h >> w;
        if (w == 0) {
            break;
        }
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                cin >> map_[j][i];
            }
        }
        int x = 0;
        int y = 0;
        while (true) {
            if (map_[x][y] == '.') {
                cout << x << ' ' << y << endl;
                break;
            }
            if (map_[x][y] == 'L') {
                cout << "LOOP" << endl;
                break;
            }
            c = map_[x][y];
            map_[x][y] = 'L';
            switch (c) {
                case '>':
                    x++;
                    break;
                case '<':
                    x--;
                    break;
                case 'v':
                    y++;
                    break;
                case '^':
                    y--;
                    break;
            }
        }
    }
    return 0;
}