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

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

#define RIGHT '>'
#define LEFT '<'
#define TOP '^'
#define UNDER 'v'
#define LOOP 'l'
#define END '.'
#define MAX 101

void dfs(char mp[MAX][MAX],int i,int j){
    if(mp[i][j]==END){
        cout << j << ' ' << i << endl;
        return;
    }
    if(mp[i][j]==LOOP){
        cout << "LOOP" << endl;
        return;
    }
    
    if(mp[i][j]==RIGHT){
        mp[i][j] = LOOP;
        dfs(mp,i,j+1);
    }
    else if(mp[i][j]==LEFT){
        mp[i][j] = LOOP;
        dfs(mp,i,j-1);
    }
    else if(mp[i][j]==TOP){
        mp[i][j] = LOOP;
        dfs(mp,i-1,j);
    }
    else{
        mp[i][j] = LOOP;
        dfs(mp,i+1,j);
    }
}


int main(){
    char mp[MAX][MAX];
    int n,m;
    
    while(true){
        cin >> n >> m;
        if(!n&&!m) break;
        
        for(int i = 0 ; i < n ; i++)
            for(int j = 0 ; j < m ; j++)
                cin >> mp[i][j];
        
        dfs(mp,0,0);
    }
    
    return 0;
}