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 <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;
}