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 <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>

int main() {
  int w, h;
  while(cin >>h >>w && w){
    vector<string> v(h);
    REP(i, h) cin >>v[i];
    vector< vector<bool> > visited(h, vector<bool>(w, false));
    int ny = 0, nx = 0;
    while(v[ny][nx] != '.' && !visited[ny][nx]){
      visited[ny][nx] = true;
      if(v[ny][nx] == '>') ++nx;
      if(v[ny][nx] == '<') --nx;
      if(v[ny][nx] == 'v') ++ny;
      if(v[ny][nx] == '^') --ny;
    }
    if(!visited[ny][nx]) cout <<nx <<" " <<ny <<endl;
    else cout <<"LOOP" <<endl;
  }
  return 0;
}

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

char c[101][101] = { 0 };
int x, y;

void move_tile() {
	if (c[y][x] == '^') {
		c[y][x] = 'l';
		y = y - 1;
		move_tile();
	}
	else if (c[y][x] == 'v') {
		c[y][x] = 'l';
		y = y + 1;
		move_tile();
	}
	else if (c[y][x] == '<') {
		c[y][x] = 'l';
		x = x - 1;
		move_tile();
	}
	else if (c[y][x] == '>') {
		c[y][x] = 'l';
		x = x + 1;
		move_tile();
	}
	else {
		return;
	}

}

int main(void) {
	while (1) {
		int h, w;
		cin >> h >> w;
		if (h == 0)return 0;
		for (int i = 0; i <h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> c[i][j];
			}
		}

		x = y = 0;
		move_tile();

		if (c[y][x] == 'l') {
			cout << "LOOP" << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}

}

C++: #include <cstdio>

#define MAX (105)

void search(int x, int y);

int h, w;
char data[MAX][MAX];
char flag[MAX][MAX];

int main(void)
{
    int i, j;
    
    while (1){
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) break;
        for (i = 0; i < MAX; i++){
            for (j = 0; j < MAX; j++){
                data[i][j] = '\0';
                flag[i][j] = '0';
            }
        }
        for (i = 0; i < h; i++){
            scanf("%s", data[i]);
        }
        search(0, 0);
    }
    
    return (0);
}

void search(int x, int y)
{
    if (flag[x][y] == '1'){
        printf("LOOP\n");
        return;
    }
    if (data[x][y] == '.'){
        printf("%d %d\n", y, x);
        return;
    }
    if (data[x][y] == '>'){
        flag[x][y] = '1';
        search(x, y + 1);
    }
    else if (data[x][y] == '<'){
        flag[x][y] = '1';
        search(x, y - 1);
    }
    else if (data[x][y] == '^'){
        flag[x][y] = '1';
        search(x - 1, y);
    }
    else if (data[x][y] == 'v'){
        flag[x][y] = '1';
        search(x + 1, y);
    }
    
}

C++: #include<iostream>

using namespace std;
int H, W;
int x = 0, y = 0;
int rog[100][100];
bool check(){
	if (rog[x][y] == 0){
		cout << "LOOP" << endl;
		return true;
	}
	else{
		return false;
	}
}
int main(){
	char map[100][100];

	while (cin >> H >> W,W+H){

		int x = 0, y = 0;
		map[100][100] = {};
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> map[j][i];
				rog[j][i] = 1;
			}
		}
		while (1){
			if (map[x][y] == '>'){
				x++;
				if (check() == true){ break; }
			}
			else if(map[x][y]=='v'){
				y--;
				if (check() == true){ break; }
			}
			else if (map[x][y] == '<'){
				x--;
				if (check() == true){ break; }
			}
			else if (map[x][y] == '^'){
				y++;
				if (check() == true){ break; }
			}
			else {
				cout << x << " " << y << endl;
				break;
			}
			
			rog[x][y] = 0;

		}
	}
	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime> 

using namespace std;

char tile[11][11];

void loop(int x,int y){
	if(tile[x][y]=='.'){
		cout << y << ' ' << x << endl;
		return;
	}
	if(tile[x][y]=='#'){
		cout << "LOOP" << endl;
		return;
	}
	if(tile[x][y]=='>'){
		tile[x][y]='#';
		loop(x,y+1);
	}
	if(tile[x][y]=='<'){
		tile[x][y]='#';
		loop(x,y-1);
	}
	if(tile[x][y]=='^'){
		tile[x][y]='#';
		loop(x-1,y);
	}
	if(tile[x][y]=='v'){
		tile[x][y]='#';
		loop(x+1,y);

	}
}

int main(void){
	int h,w;
	int x,y;
	int a;
	while(1){
		x=0,y=0;
		cin >> h >> w;
		if(h==0 && w==0)break;
		for(a=0;a<h;a++){
			cin >> tile[a];
		}
		loop(0,0);
	}
	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];
   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(map[x][y]=='>') 
       {
         x++;
         step++;
         cout<<">"<<" ";                      
       }        
       if(map[x][y]=='<')
       {
         x--;
         step++;   
         cout<<"<"<<" ";                   
       }
       if(map[x][y]=='v')
       {
         y++;
         step++;         
         cout<<"v"<<" ";             
       }
       if(map[x][y]=='^')
       {
         y--;
         step++;         
         cout<<"^"<<" ";             
       }
       if(step>(w*h))
       {
         flag=true;
         break;            
       }
       if(map[x][y]=='.')
       {
         break;                  
       }
     }        
     if(flag) cout<<"LOOP"<<endl;
     else cout<<x<<" "<<y<<endl;
   }
   //while(1);
   return 0;
 }

C++: #include<iostream>

int w,h;

int d[100][100];
char c;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int main(){
	while( std::cin>>h>>w , (w || h) ){
		memset(d,-1,sizeof(d));
		for(int i=0;i<h;++i){
			for(int l=0;l<w;++l){
				std::cin>>c;
				if( c=='>' )
					d[l][i]=0;
				else if( c=='v' )
					d[l][i]=1;
				else if( c=='<' )
					d[l][i]=2;
				else if( c=='^' )
					d[l][i]=3;
			}
		}
		int Point[2]={0,0};
		while(1){
			if( d[Point[0]][Point[1]] == -1 ){
				break;
			}else if( d[Point[0]][Point[1]] < 4 ){
				int dnum=d[ Point[0] ][ Point[1] ];
				d[Point[0]][Point[1]]=4;
				Point[0]+=dx[ dnum ];
				Point[1]+=dy[ dnum ];
			}else{
				Point[0] = Point[1] = -1;
				break;
			}
		}
		if( Point[0]==-1 && Point[1]==-1 ){
			std::cout<<"LOOP"<<std::endl;
		}else{
			std::cout<<Point[0]<<" "<<Point[1]<<std::endl;
		}
	}
}