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>
using namespace std;
int main(){
	int H,W;
	char c,tail[101][101];
	while(cin>>H>>W&&H!=0&&W!=0){
		bool z[101][101]={0};
		int x=0,y=0,cnt=0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>tail[i][j];
			}
		}
		for(int i=0;i<H*W;i++){
			if(tail[x][y]=='>'){
				if(z[x][y]==1)break;
				z[x][y]=1;
				y+=1;
			}else if(tail[x][y]=='<'){
				if(z[x][y]==1)break;
				z[x][y]=1;
				y-=1;
			}else if(tail[x][y]=='^'){
				if(z[x][y]==1)break;
				z[x][y]=1;
				x-=1;
			}else if(tail[x][y]=='v'){
				if(z[x][y]==1)break;
				z[x][y]=1;
				x+=1;
			}else{
				cnt=1;
				cout<<y<<" "<<x<<endl;
				break;
			}
		}
		if(cnt==0)cout<<"LOOP"<<endl;
	}
	return 0;
}

C++: 

#include<iostream>
#include<vector>
#include<string>

using namespace std;

char f[101][101];
int judge[101][101];
int ex, ey;

void move(int i, int j)
{
	//printf("%3d:%3d\n", i, j);
	if(judge[i][j] == 1)
	{
		ex = -1; ey = -1;
		return;
	}
	else if(f[i][j] == '.')
	{
		ex = j; ey = i;
		return;
	}

	judge[i][j] = 1;

	if(f[i][j] == '>')
	{
		move(i, j+1);
	}
	else if(f[i][j] == '<')
	{
		move(i, j-1);
	}
	else if(f[i][j] == '^')
	{
		move(i-1, j);
	}
	else if(f[i][j] == 'v')
	{
		move(i+1, j);
	}

}

int main()
{
	int w, h;
	while(cin >> h >> w)
	{
		if(h == 0 && w == 0) break;
		for(int i = 0; i < h; i++)
		{
			cin >> f[i];
		}
		/*
		   for(int i = 0; i < h; i++)
		   {
		   for(int j = 0; j < w; j++)
		   {
		   cout << f[i][j];
		   }
		   cout << endl;
		   }
		   */
		//cout << "Run" << endl;
		move(0, 0);
		//cout << "Finish" << endl;

		if(ex == -1 && ey == -1)
		{
			cout << "LOOP" << endl;
		}
		else
		{
			cout << ex << ' ' << ey << endl;
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

bool visited[120][120];
char field[120][120];

int main(){
    int h,w,i;

    while( cin >> h >> w, h|w ){
        // init
        memset(visited, false, sizeof(visited));

        // input
        rep(i,h) cin >> field[i];

        int x = 0, y = 0;
        visited[y][x] = true;
        while( true ){
            switch( field[y][x] ){
            case '>': x++; break;
            case '<': x--; break;
            case '^': y--; break;
            case 'v': y++; break;
            default: break;
            }
            if( field[y][x] == '.' ){
                printf("%d %d\n",x,y);
                break;
            }
            if( visited[y][x] ){
                puts("LOOP");
                break;
            }
            visited[y][x] = true;
        }
    }

    return 0;
}

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

int main(){
	string map[110];
	int w, h;
	bool f[110][110], flag;

	while( cin >> w >> h , w , h ){
		for(int i=0 ; i<110 ; i++){
			map[i].clear();
		}
		for(int y=0 ; y<110 ; y++){
			for(int x=0 ; x<110 ; x++){
				f[y][x] = false;
			}
		}
		flag = false;

		for(int i=0 ; i<h ; i++){
			cin >> map[i];
		}
		int x=0,y=0;
		while( map[y][x] != '.' ){
			f[y][x] = true;
			if( map[y][x] == '>' ){
				x++;
			}else if( map[y][x] == '<' ){
				x--;
			}else if( map[y][x] == 'v' ){
				y++;
			}else if( map[y][x] == '^' ){
				y--;
			}

			if(f[y][x]){
				flag = true;
				break;
			}
		}
		(flag)? cout << "LOOP" << endl : cout << x << y << endl;
	}

	return 0;
}

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

using namespace std;

int main(){
	char map[100][100];
	int w, h, x = 0, y = 0, lx, ly, c;

	while (1){
		c = 0;

		cin >> h >> w;

		if (w == 0 && h == 0)break;

		//input
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> map[i][j];
				cout << map[i][j];
			}
			cout << endl;
		}

		//detect
		while(1){
			c++;
			
			if (c > w*h){
				lx = -1;
				ly = -1;
				break;
			}

			switch (map[y][x]){
			case '>':x++; break;
			case '<':x--; break;
			case '^':y--; break;
			case 'v':y++; break;
			}

			if (map[y][x] == '.'){
				lx = x; ly = y;
				break;
			}
		}

		if (lx == -1 && ly == -1){
			cout << "LOOP" << endl;
		}
		else{
			cout << lx << ' ' << ly << endl;
		}

		x = y = 0;
	}

	return 0;
}

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

int w,h;
char t[102][102];

int dx[128];
int dy[128];

int main(void){
	dx['>'] = 1;
	dx['<'] = -1;
	dy['v'] = 1;
	dy['^'] = -1;

	while(cin>>h>>w && (h||w)){
		for(int i=0;i<h;i++){
			cin>>t[i];
		}

		int x = 0, y = 0;
		while(t[y][x] != '?' && t[y][x] != '.'){
			int nx = x + dx[t[y][x]];
			int ny = y + dy[t[y][x]];
			t[y][x] = '?';
			x = nx;
			y = ny;
		}
		if(t[y][x] == '?'){
			cout<<"LOOP\n";
		}
		else{
			cout<<x<<" "<<y<<endl;
		}
	}

	return 0;
}

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

int main(){
  int w,h;
  char map[100][100];
  int x,y;

  while(1){
    cin >> h >> w;
    if(!h && !w)break;

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

    x = 0;
    y = 0;
    int count = 0;
    int flag = 0;
    while(1){
      count++;
      if(map[y][x] == '^')y--;
      if(map[y][x] == '>')x++;
      if(map[y][x] == 'v')y++;
      if(map[y][x] == '<')x--;
      if(map[y][x] == '.')break;
      if(count>h*w){
	flag = 1;
	break;
      }
    }
    if(flag)cout << "LOOP" << endl;
    else cout << x << " " << y << endl;
  }
}

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;
		}
		
		array1 = (int *)calloc(n*m, sizeof(int));
		array2 = (int *)calloc(n*m, 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;
}