Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	// var w, h int
	for scanner.Scan() {
		// fmt.Scanf("%d %d", &w, &h)

		input := strings.Split(scanner.Text(), " ")
		w, _ := strconv.Atoi(input[0])
		h, _ := strconv.Atoi(input[1])

		if w == 0 && h == 0 {
			return
		}

		isArrive := make([][]bool, w)
		tiles := make([][]string, w)

		for i := 0; i < w; i++ {
			rowArrive := make([]bool, h)
			rowTiles := make([]string, h)
			scanner.Scan()
			row := scanner.Text()
			for j := 0; j < h; j++ {
				rowTiles[j] = string(row[j])
			}
			tiles[i] = rowTiles
			isArrive[i] = rowArrive
		}

		var i, j int
		isEnd := false
		for {
			if isArrive[i][j] == true {
				fmt.Println("LOOP")
				break
			}
			isArrive[i][j] = true

			switch tiles[i][j] {
			case ">":
				j++
			case "^":
				i--
			case "v":
				i++
			case "<":
				j--
			case ".":
				isEnd = true
			}

			if isEnd == true {
				fmt.Println(j, i)
				break
			}
		}
	}
}

C++: #include<stdio.h>
int a,b,limx,limy;
char s[102][102];
int pass[102][102];
void check(int x,int y){
    if(pass[x][y]!=1){
        a=x,b=y;
        pass[x][y]=1;
        if(s[x][y]=='^'&&x-1>=0)
        check(x-1,y);
        if(s[x][y]=='v'&&x+1<limx)
        check(x+1,y);
        if(s[x][y]=='>'&&y+1<limy)
        check(x,y+1);
        if(s[x][y]=='<'&&y-1>=0)
        check(x,y-1);
    }
    else
    a=-1;
}
main(){
    int x,y,i,j;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)
        break;
        limx=x;limy=y;
        for(i=0;i<x;i++)
        for(j=0;j<y;j++)
        pass[x][y]=0;
        for(i=0;i<x;i++)
        scanf("%s",&s[i]);
        check(0,0);
        if(a!=-1)
        printf("%d %d\n",b,a);
        else
        printf("LOOP\n");
    }
}

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++){
			cin >> s[i];
		}
		move(0,0);

	}
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int H, W; cin >> H >> W&&H;) {
		char c[12][12] = {};
		rep(i, 0, H)rep(j, 0, W)cin >> c[i][j];
		int cnt[12][12] = {};
		int i = 0, j = 0;
		while (true) {
			cnt[i][j]++;
			if (cnt[i][j] > 10) {
				cout << "LOOP" << endl;
				break;
			}
			else {
				bool flag = false;
				switch (c[i][j])
				{
				case '.':
					cout << j << " " << i << endl;
					flag = true;
					break;
				case '>':
					j++;
					break;
				case '<':
					j--;
					break;
				case '^':
					i--;
					break;
				case 'v':
					i++;
					break;
				default:
					break;
				}
				if (flag)break;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    while(true){
    char a[100][100];
    int h,w,n=0;
    cin>>h>>w;
    if(h==0 && w==0){
        exit(1);
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    h=0;
    w=0;
    n=0;
    while(true){
        n+=1;
        if(a[h][w]=='.'){
            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 <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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

int H,W;
char field[110][110];
map<char,int> dx;
map<char,int> dy;

void make(){
  dx['^'] = 0;  dy['^'] = -1;
  dx['v'] = 0;  dy['v'] = 1;
  dx['>'] = 1;  dy['>'] = 0;
  dx['<'] = -1; dy['<'] = 0;
}

pair<int,int> func(int i, int j){
  if(field[i][j] == '.') return make_pair(i,j);
  int cnt = 0;

  while(1){
    if(i < 0 || j < 0 || i >= H || j >= W) continue;
    cnt++;
    i += dy[field[i][j]];
    j += dx[field[i][j]];
    if(field[i][j] == '.') return make_pair(i,j);
    if(cnt > 10000) break;
  }

  return make_pair(-1,-1);
}

int main(){
  int i,j,k;

  make();
  for(; ~scanf("%d %d",&H,&W); ){
    if(H == 0 && W == 0) break;

    rep(i,H) scanf("%s",&field[i]);

    pair<int,int> res = func(0,0), out(-1,-1);
    if(res == out) puts("LOOP");
    else printf("%d %d\n",res.second,res.first);
  }

  return 0;
}

C++: #include<iostream>

std::pair<char,bool> data[101][101];

int main(){
	int w,h;
	while(std::cin>>w>>h){
		if(w==0&&h==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				std::cin>>data[i][j].first;
				data[i][j].second=false;
			}
		}
		int x=0,y=0;
		while(true){
			if(data[y][x].second){
				std::cout<<"LOOP"<<std::endl;
				break;
			}else data[y][x].second=true;

			if(data[y][x].first=='^')y--;
			if(data[y][x].first=='>')x++;
			if(data[y][x].first=='v')y++;
			if(data[y][x].first=='<')x--;

			if(data[y][x].first=='.'){
				std::cout<<x<<" "<<y<<std::endl;
				break;
			}
		}
	}
	return 0;
}