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>

using namespace std;

int main()
{
	int h, w;
	
	while (cin >> h >> w,h || w){
		int map = h * w;
		char f[101][101];
		for (int i = 0; i < h; i++){
			cin >> f[i];
		}
		h = w = 0;
		while (map){
			if (f[h][w] == '>'){
				w++;
			}
			else if (f[h][w] == '<'){
				w--;
			}
			else if (f[h][w] == '^'){
				h--;
			}
			else if (f[h][w] == 'v'){
				h++;
			}
			else if (f[h][w] == '.'){
				break;
			}
			map--;
		}
		if (map == 0){
			cout << "LOOP" << endl;
		}
		else {
			cout << w << ' ' << h << endl;
		}
	}
	
	return (0);
}

C++: #include <iostream>
#include <stdlib.h>

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;
		}
		if(n*m > 2){
			array1 = (int *)calloc(n*m, sizeof(int));
			array2 = (int *)calloc(n*m, sizeof(int));
		} else {
			array1 = (int *)calloc(2, sizeof(int));
			array2 = (int *)calloc(2, sizeof(int));
		}
		
		for(i = 0; i < n; i++){
			for(j = 0, tmp = i*m; j < m; j++){
				cin >> w;
				
				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;
				}
			}
		}
		
		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>
using namespace std;
int main(){
  int H,W,x,y;
  while(cin>>H>>W){
    if(H==0&&W==0) break;
    char space[W][H],c;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> space[j][i];
      }
    }
    x = y = 0;
    while(1){
      c = space[x][y];
      space[x][y] = '0';
      if(c=='>') x++;
      else if(c=='<') x--;
      else if(c=='v') y++;
      else if(c=='^') y--;
      else if(c=='.'){
	cout << x << ' ' << y << endl;
	break;
      }
      else if(c=='0'){
	cout << "LOOP" << endl;
	break;
      }
    }
  }
  return 0;
}