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

int main(){
    int w,h;
    int ichi[101][101]={0};
    while(1){
        int i=0,j=0;
        cin >> w >> h;
        if(w == 0 && h == 0){
            break;
        }
        char map[w][h];
        for(int n=0;n<w;n++){
            for(int k=0;k<h;k++){
                cin >> map[n][k];
            }
        }
        while(1){
            for(int n=0;n<w;n++){
                memset(ichi[n],0,sizeof(ichi[i]));
            }
            if(ichi[i][j] == 1){
                cout << "LOOP" << endl;
                break;
            }
            else if(map[i][j] == '.'){
                cout << j << " " << i << endl;
                break;
            }
            if(map[i][j] == '>'){
                ichi[i][j] = 1;
                j++;
            }
            else if(map[i][j] == '<'){
                ichi[i][j] = 1;
                j--;
            }
            else if(map[i][j] == '^'){
                ichi[i][j] = 1;
                i--;
            }
            else if(map[i][j] == 'v'){
                ichi[i][j] = 1;
                i++;
            }
        }
    }
}

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

using namespace std;

int main() {

  while(1) {

    long long int w, h;
    cin >> w >> h;

    if ( w == 0 ) break;

    vector< string > m;

    for ( long long int i = 0; i < w; i++ ) {

      string in;
      cin >> in;
      m.push_back( in );

    }

    bool f[101][101] = {};

    long long int x = 0;
    long long int y = 0;

    for (;;) {

      if ( m[y][x] == '.' ) {
	cout << x << " " << y << endl;
	break;
      }else if ( m[y][x] == '>' ) {
	x++;
      }else if ( m[y][x] == '<' ) {
	x--;
      }else if ( m[y][x] == '^' ) {
	y--;
      }else if ( m[y][x] == 'v' ) {
	y++;
      }
      if ( f[y][x] == true ) {
	cout << "LOOP" << endl;
	break;
      }
      f[y][x] = true;

    }

  }

  return 0;

}

C++: #include <iostream>
#include <cstdlib>
#include <cstring>

using namespace std;

int main(int argc, char **argv)
{
	int *array1, *array2, n, m, tmp, i, j;
	char w;
	
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0){
			break;
		}
		
		array1 = (int *)calloc(n*m+2, sizeof(int));
		array2 = (int *)calloc(n*m+2, sizeof(int));
		for(i = 0; i < n; i++){
			for(j = 0, tmp = i*m; j < m; j++){
				cin >> w;
				if(tmp < 0){
					break;
				}
				if(w == '>'){
					array1[tmp+j] = tmp + j + 1;
				} else if(w == 'v'){
					array1[tmp+j] = tmp + j + m;
				} else if(w == '<'){
					array1[tmp+j] = tmp + j -1;
				} else if(w == '^'){
					array1[tmp+j] = tmp + j - m;
				} else {
					array1[tmp+j] = -1;
				}
			}
			if(tmp < 0){
				break;
			}
		}
		if(tmp < 0){
			cout << "LOOP" << endl;
			free(array1);
			free(array2);
			continue;
		}
		
		tmp = array1[0];
		array2[0] = 1;
		while(1){
			if(array2[tmp] == 1){
				cout << "LOOP" << endl;
				break;
			} else if(array1[tmp] == -1){
				i = tmp % m;
				j = (int)(tmp / m);
				cout << i << " " << j << endl;
				break;
			}
			array2[tmp] = 1;
			tmp = array1[tmp];
		}		
		
		free(array1);
		free(array2);
	}
	
	return 0;
}

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

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

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

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

int main(){
	int w,h;
	std::cin>>w>>h;
	while(w!=0||h!=0){
		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-=1;
			else if(data[y][x].first=='>')x+=1;
			else if(data[y][x].first=='v')y+=1;
			else if(data[y][x].first=='<')x-=1;

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

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int h,w;
  while(cin>>h>>w,h+w) {
    char ba[h][w];
    REP(y,h) {
      REP(x,w) {
        cin >> ba[x][y];
      }
    }
    int x = 0, y = 0;
    int dx[] = {0,1,0,-1};
    int dy[] = {-1,0,1,0};
    char aa[] = {'^','>','v','<'};
    map<char,int> hoge;
    REP(i,4)
      hoge[aa[i]] = i;
    int f[w][h];
    memset(f,0,sizeof(f));
    while(true) {
      if (f[x][y]) break;
      if (ba[x][y] == '.') break;

      f[x][y]=1;
      x += dx[hoge[ba[x][y]]];
      y += dy[hoge[ba[x][y]]];
    }
    if (f[x][y]) cout << "LOOP" << endl;
    else cout << x << " " << y << endl;
  }
}

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

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

using namespace std;

int main(){
  int w,h;
  char cmap[200][200];
  bool used[200][200];

  while(true){
    cin >> w >> h;
    if(w+h == 0)break;
    for(int i=0;i<200;i++)for(int j=0;j<200;j++)used[i][j]=false;

    for(int i=0;i<w;i++){
      for(int j=0;j<h;j++){
	cin >> cmap[i][j];
	used[i][j]=false;
      }
    }

    int x,y;
    x=y=0;
    bool fin=false;

    while(!used[y][x] && cmap[y][x] != '.'){
      used[y][x] = true;
      if(cmap[y][x] == '>' && x+1 <h){
	x++;
      }
      else if(cmap[y][x] == 'v' && y+1 < w){
	y++;
      }
      else if(cmap[y][x] == '^' && y-1 >= 0){
	y--;
      }
      else if(cmap[y][x] == '<' && x-1 >= 0){
	x--;
      }

      if(used[y][x]){
	cout << "LOOP" << endl;
 	fin = true;
      }
    }
    if(!fin){
      cout << x << " " << y << endl;
    }






  }

  return 0;
}