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>
using namespace std;

char tile[101][101];
bool flag[101][101];

int solve(int x,int y){
	if(flag[x][y]) return -1;
	int ans;
	
	flag[x][y]=true;
	switch(tile[x][y]){
	case '>':
		ans=solve(x+1,y);
		break;
	case '<':
		ans=solve(x-1,y);
		break;
	case 'v':
		ans=solve(x,y+1);
		break;
	case '^':
		ans=solve(x,y-1);
		break;
	case '.':
		ans=x*1000+y;
		break;
	default:
		break;
	}
	return ans;
}

int main(){
	int W,H,ans;

	while(1){
		cin>>W>>H;
		if(W==0&&H==0) break;
	
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>tile[j][i];
			}
		}
		if((ans=solve(0,0))==-1) cout<<"LOOP"<<endl;
		else cout<<ans/1000<<" "<<ans%1000<<endl;
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int px,py; 
int w,h,f[100][100];
 
bool cheak(){
  if(f[px][py] == 0){
    cout << "LOOP" << endl;
    return true;
  }
  return false;
}
 
int main(){
 
  char ma[100][100];
  while(  cin >> h >> w,w + h ){
    for(int i = 0 ; i < h ; i++){
      for(int j = 0 ; j < w ; j++){
    cin >> ma[j][i];
    f[j][i] = 1;
      }
    }
 
    px = 0,py = 0; 
    while(1){
      if(ma[px][py] == '>' ){
    px++;
    if(cheak())break;
      } else if(ma[px][py] == 'v' ){
    py++;
    if(cheak())break;
      }else if(ma[px][py] == '<' ){
    px--;
    if(cheak())break;
      }else if(ma[px][py] == '^' ){
    py--;
    if(cheak())break;
      } else {
    cout << px << " " << py << endl;
    break;
      }
      f[px][py] = 0;
    }
  }
}

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

int main(){
   int a, b, i, j;
   char map[102][102];
   
   while(1){
      cin >> a >> b;
      if(a+b==0) break;
      
      for(i=0; i< a; i++){
         for(j=0; j< b; j++){
            cin >> map[i][j];
         }
      }
      for(i=0; i< a; i++){
         for(j=0; j< b; j++){
            cout << map[i][j];
         }
         cout << endl;
      }
      cout << endl;
      i=0,j=0;
      while(1){
         if(map[i][j]=='.'){
            cout << j << " " << i << endl;
            break;
         }else if(map[i][j]=='#'){
            cout << "loop" << endl;
            break;
         }else if(map[i][j]=='>'){
            map[i][j]='#';
            j++;
         }else if(map[i][j]=='<'){
            map[i][j]='#';
            j--;
         }else if(map[i][j]=='^'){
            map[i][j]='#';
            i--;
         }else if(map[i][j]=='v'){
            map[i][j]='#';
            i++;
         }
      }
   }
   return 0;
}

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

int main() {
	
	int w,h;
	int *tile;
	int tmp;
	int x,y;
	
	while(cin>>h>>w,w||h){
		tile = new int[w*h];
		x=y=0;
		
		for(int i=0;i<w*h;++i){
			tmp = getchar();
			if(tmp == '\n'){--i;continue;}
			tile[i] = tmp;
		}
		
		while(1){
			
			if(tile[x+y*w] == 0){
				cout<<"LOOP"<<endl;
				break;
			}
			
			if(tile[x+y*w] == '.'){
				cout<<x<<" "<<y<<endl;
				break;
			}
			
			tmp = tile[x+y*w];
			
			tile[x+y*w] = 0;
			
			
			switch(tmp){
				
				case '>':
				++x;
				break;
				
				case '<':
				--x;
				break;
				
				case '^':
				--y;
				break;
				
				case 'v':
				++y;
				break;
			}
		}
	}

	delete[]tile;
	
	return 0;
}

C++: #include<iostream>
using namespace std;
#define UUI long long int
UUI x,y,n,m;
char tile[120][120],a;
int main(){
    while(1){
            cin >> n >> m;
            if(n==0&&m==0)break;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a;
            tile[i][j]=a;
        }
    }
    x=0;
    y=0;
    for(int i=0;i<11000;i++){
            if(tile[y][x]==0){
                    cout << "LOOP" << endl;
                    break;
            }
    if(tile[y][x]=='>'){
        tile[y][x]=0;
        x=x+1;
    }else if(tile[y][x]=='<'){
        tile[y][x]=0;
        x=x-1;
    }else if(tile[y][x]=='^'){
        tile[y][x]=0;
        y=y-1;
    }else if(tile[y][x]=='v'){
        tile[y][x]=0;
        y=y+1;
    }else if(tile[y][x]=='.'){
            cout << y <<" "<< x << endl;
        break;
    }
    }
      for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            tile[i][j]=0;
        }
    }
    }
return 0;
}

C++: #include <stdio.h>
#include <queue>
using namespace std;
typedef pair<int,int> P;

int main()
{
	int x,y;
	char map[100][101];
	bool visited[100][100];
	char mapkind[5] = {"><^v"};
	int tx[4] = {1,-1,0,0},ty[4] = {0,0,-1,1};
	queue<P> que;
	P now;

	scanf("%d%d",&y,&x);

	while(x != 0 && y != 0){
		for(int i = 0; i < y; i++){
			for(int j = 0; j < x; j++){
				visited[i][j] = false;
			}
		}
		for(int i = 0; i < y; i++){
			scanf("%s",map[i]);
		}

		now.first = 0; now.second = 0;
		que.push(now);

		while(!que.empty()){
			now = que.front();
			for(int i = 0; i < 4; i++){
				if(map[now.second][now.first] == mapkind[i]){
					if(now.second + ty[i] >= 0 && now.second + ty[i] < y 
					&& now.first + tx[i] >= 0 && now.first + tx[i] < x
					&& !visited[now.second + ty[i]][now.first + tx[i]] ){
						visited[now.second + ty[i]][now.first + tx[i]] = true;
						now.second += ty[i];
						now.first += tx[i];
						que.push(now);
						break;
					}
				}
			}
			que.pop();
		}

		if(map[now.second][now.first] == '.'){
			printf("%d %d\n",now.first,now.second);
		}
		else{
			printf("Loop\n");
		}

		scanf("%d%d",&y,&x);
	}
	
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
int main() {
 
  int w, h;
  while( cin >> h >> w, w+h ) {
    char room[101][101];
    bool flag[101][101];
    int now_x = 0, now_y = 0;
 
    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) {
    cin >> room[i][j];
    flag[i][j] = false;
      }
    }
 
    while(1) {
      if( flag[now_y][now_x] || room[now_y][now_x] == '.' ) break;
      char c = room[now_y][now_x];
      flag[now_y][now_x] = true;
      
 
      if( c == '>' ) {
    while( room[now_y][now_x] == c ) {
      now_x++;
    }
      }
      if( c == '<' ) {
    while( room[now_y][now_x] == c ) {
      now_x--;
    }
      }
      if( c == 'v' ) {
    while( room[now_y][now_x] == c ) {
      now_y++;
    }
      }
      if( c == '^' ) {
    while( room[now_y][now_x] == c ) {
      now_y--;
    }
      }
    }
 
    if( room[now_y][now_x] != '.' ) cout << "LOOP" << endl;
    else cout << now_x << " " << now_y << endl;
  }
}