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

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int w,h;
   bool flag=false;
   char map[100+5][100+5];
   int map2[100+5][100+5]={{0}};
   while(cin>>w>>h&&(w||h))
   {
     for(int i=0;i<h;i++)
     {
       for(int j=0;j<w;j++)
       {
         cin>>map[i][j];        
       }        
     }               
     int step=0;
     int x=0;
     int y=0;
     while(1)
     {
       if(map2[x][y]==1) 
       {
         flag=true;
         break;                  
       }
       if(map[x][y]=='>') 
       {
         map2[x][y]=1;
         y++;
         step++;
         //cout<<">"<<" ";                      
       }        
       if(map[x][y]=='<')
       {
         map2[x][y]=1;
         y--;
         step++;   
         //cout<<"<"<<" ";                   
       }
       if(map[x][y]=='v')
       {
         map2[x][y]=1;
         x++;
         step++;         
         //cout<<"v"<<" ";             
       }
       if(map[x][y]=='^')
       {
         map2[x][y]=1;
         x--;
         step++;         
         //cout<<"^"<<" ";             
       }
       if(step>(w*h))
       {
         flag=true;
         break;            
       }
       if(map[x][y]=='.')
       {
         break;                  
       }
       if(flag) break;
     }        
     if(flag) cout<<"LOOP"<<endl;
     else cout<<y<<" "<<x<<endl;
   }
   //while(1);
   return 0;
 }

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

int main()
{
	int w, h;

	while( cin >> h >> w && !( h == 0 && w == 0 ) ){
		char* field = new char[ h * w ]();
		int x, y; x = y = 0;
		bool advance = true;
		for( int i = 0; i < h; ++i ){
			for( int j = 0; j < w; ++j ){
				cin >> field[ i * w + j ];
			}
		}
		while( advance ){
			char tile = field[ y * w + x ];
			field[ y * w + x ] = '*';
			switch( tile ){
				case '^': --y; break;
				case '>': ++x; break;
				case 'v': ++y; break;
				case '<': --x; break;
				case '*': advance = false; cout << "LOOP" << endl; break;
				case '.': advance = false; cout << x << " " << y << endl; break;
			}
		}
		delete[] field;
	}

	return 0;
}

C++: #include <cstring>
#include <iostream>
#define W 101
#define H 101
using namespace std;
int main() {
  int h, w, x, y;
  char m[H][W];
  bool n[H][W];
  while (cin >> h >> w && h > 0) {
    memset(m, '.', sizeof(char) * H * W);
    memset(n, 0, sizeof(bool) * H * W);
    for (y = 0; y < h; y++) {
      cin >> m[y];
    }
    x = y = 0;
    while (1) {
      if (n[y][x]) {
        cout << "LOOP" << endl;
        break;
      }
      n[y][x] = 1;
      if (m[y][x] == '^') y--;
      else if (m[y][x] == '>') x++;
      else if (m[y][x] == 'v') y++;
      else if (m[y][x] == '<') x--;
      else {
        cout << x << ' ' << y << endl;
        break;
      }
    }
  }
  return 0;
}

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

int main(){
	int w,h,x,y;
	char tile[100][100];
	bool use[100][100];
	bool flg;
	
	while(1){
	 cin>>h>>w;
	 if(w==0 && h==0){break;}
	 for(y=0;y<h;y++){
	  for(x=0;x<w;x++){
	   cin>>tile[x][y];
	   use[x][y]=false;
	  }
	 }
	 
	 x=0;y=0;flg=true;
	 do{
	  if(use[x][y]){cout<<"LOOP"<<endl;break;}
	  use[x][y]=true;
	  switch(tile[x][y]){
		case '.':
		flg=false;
		cout<<x<<" "<<y<<endl;
		break;

		case '>':
		x+=1;
		break;

		case '<':
		x-=1;
		break;

		case '^':
		y-=1;
		break;

		case 'v':
		y+=1;
		break;
	  }
	 }while(flg);
	}
}

C++: #include <iostream>
#include <string>
using namespace std;
int loop_counter[100][100]={0};
string board[100];
int loop(int y,int x){

	if(loop_counter[y][x]){
		cout<<"LOOP"<<endl;
		return 0;
	}
	loop_counter[y][x]=1;
	if(board[y][x]=='^'){
		return loop(y-1,x);
	}
	else if(board[y][x]=='v'){
		return loop(y+1,x);
	}
	else if(board[y][x]=='<'){
		return loop(y,x-1);
	}
	else if(board[y][x]=='>'){
		return loop(y,x+1);
	}
	else if(board[y][x]=='.'){
		cout << x <<" "<<y<<endl;
		return 0;
	}
	return 0;
}
int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h==0 && w==0)
			return 0;
		for(int i=0 ; i<h ; i++ )
			cin >> board[i];
		loop(0,0);
	}
}

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

using namespace std;

struct Point{
	short x;
	short y;
};

int change( const Point& point)
{
	return point.x + point.y * 200;
}
int main(int argc, char const* argv[])
{
	int H,W;
	Point place;
	set<int> data;
	string stage[101];

START:
	while( cin >> W >> H && W != 0 ){
		for( int i = 0;i < W;i++ ) cin >> stage[i];

		data.clear();
		place.x = 0;
		place.y = 0;
		while( 1 ){
			switch( stage[place.x][place.y] ){
				case '>':
					place.y++;
					if( data.count( change( place ) ) ){
						cout << "LOOP" << endl;
						goto START;
					}
					data.insert( change( place ) );
					break;
				case '<':
					place.y--;
					if( data.count( change( place ) ) ){
						cout << "LOOP" << endl;
						goto START;
					}
					data.insert( change( place ) );
					break;
				case '^':
					place.x--;
					if( data.count( change( place ) ) ){
						cout << "LOOP" << endl;
						goto START;
					}

					data.insert( change( place ) );
					break;
				case 'v':
					place.x++;
					if( data.count( change( place ) ) ){
						cout << "LOOP" << endl;
						goto START;
					}

					data.insert( change( place ) );
					break;
				case '.':
					cout << (int)place.y << ' ' << (int)place.x << endl;
					goto START;
					break;
			}
		}
	}
	return 0;
	
}