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 <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

int W,H;
char s;


int main(){
    while(cin>>H>>W){
        if(W==0&&H==0)break;
        
        int tile[2][101][101]={0};
        bool pass[101][101]={0};
        
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cin>>s;
                if(s=='>'){
                    tile[0][i][j]=0;
                    tile[1][i][j]=1;
                }else if(s=='<'){
                    tile[0][i][j]=0;
                    tile[1][i][j]=-1;
                }else if(s=='^'){
                    tile[0][i][j]=-1;
                    tile[1][i][j]=0;
                }else if(s=='v'){
                    tile[0][i][j]=1;
                    tile[1][i][j]=0;
                }else if(s=='.'){
                    tile[0][i][j]=0;
                    tile[1][i][j]=0;
                }
            }
        }
        
        int now_w=0,now_h=0;
        while(1){
            //cout<<now_w<<" "<<now_h<<endl;
            
            if(tile[0][now_h][now_w]==0&&tile[1][now_h][now_w]==0)break;
            if(pass[now_h][now_w]==true){
                now_w=-1;
                now_h=-1;
                break;
            }
            
            pass[now_h][now_w]=true;
            int temp_h,temp_w;
            temp_h=now_h+tile[0][now_h][now_w];
            temp_w=now_w+tile[1][now_h][now_w];
            now_h=temp_h;
            now_w=temp_w;
            
        }
        
        if(now_h==-1){
            cout<<"LOOP"<<endl;
        }else{
            cout<<now_w<<" "<<now_h<<endl;
        }
        
        
        
        
    }
    
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int h,w;
  while(cin >>h>>w,h||w){
    int field[100][100] = {0};
    bool f[100][100] = {false};
    string s;
    for(int i=0; i<h; i++){
      cin >>s;
      for(int j=0; j<s.size(); j++){
	if(s[j] == '>'){field[i][j] = 1;}
	if(s[j] == 'v'){field[i][j] = 2;}
	if(s[j] == '<'){field[i][j] = 3;}
	if(s[j] == '^'){field[i][j] = 4;}
      }
    }
    int px, py;
    px = py = 0;
    for(;;){
      if(f[py][px]){cout <<"LOOP"<<endl;break;}
      f[py][px] = true;
      if(!field[py][px]){cout <<px<<" "<<py<<endl;break;}
      if(field[py][px] == 1){px++;}
      if(field[py][px] == 2){py++;}
      if(field[py][px] == 3){px--;}
      if(field[py][px] == 4){py--;}
    }
  }
  return 0;
}

C++: #include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	int w,h;
	while(cin>>h>>w&&!(w==0&&h==0)){
		vector<string> field;
		string str;
		for(int i = 0; i < h; i++){
			cin>>str;
			field.push_back(str);
		}
		bool isPassed[200][200];
		memset(isPassed,0,sizeof(isPassed));
		int sy,sx;
		sy=sx=0;
		bool f=true;
		while(1){
			if(isPassed[sy][sx]){
				f=false;
				break;
			}
			isPassed[sy][sx]=true;
			if(field[sy][sx]=='>'){
				sx++;
			}
			else if(field[sy][sx]=='<'){
				sx--;
			}
			else if(field[sy][sx]=='v'){
				sy++;
			}
			else if(field[sy][sx]=='^'){
				sy--;
			}
			else
				break;
		}
		if(!f){
			cout<<"LOOP"<<endl;
		}
		else
			cout<<sx<<" "<<sy<<endl;
	}

	return 0;
}

C++: #include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	int w,h;
	while(cin>>w>>h&&w!=0&&h!=0){
		vector<string> field;
		string str;
		for(int i = 0; i < h; i++){
			cin>>str;
			field.push_back(str);
		}
		bool isPassed[200][200];
		memset(isPassed,0,sizeof(isPassed));
		int sy,sx;
		sy=sx=0;
		bool f=true;
		while(1){
			if(isPassed[sy][sx]){
				f=false;
				break;
			}
			isPassed[sy][sx]=true;
			if(field[sy][sx]=='>'){
				sx++;
			}
			else if(field[sy][sx]=='<'){
				sx--;
			}
			else if(field[sy][sx]=='v'){
				sy++;
			}
			else if(field[sy][sx]=='^'){
				sy--;
			}
			else
				break;
		}
		if(!f){
			cout<<"LOOP"<<endl;
		}
		else
			cout<<sx<<" "<<sy<<endl;
	}

	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>>w>>h;
	 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 <cstdio>
#include <string>

using namespace std;

char mp[100][101];
const int dy[4] = {-1,0,1,0}, dx[4] = {0,1,0,-1};
const char dir[5] = "\^>v<";

char *rec(int y,int x){
	char tmp = mp[y][x];
	if(tmp == '.'){
		char ret[256];
		sprintf(ret,"%d %d",x,y);
		return ret;
	}else if(tmp == 't'){
		char ret[] = "LOOP";
		return ret;
	}
	mp[y][x] = 't';
	int d;
	for(d = 0;d < 4;d++){
		if(tmp == dir[d]){
			break;
		}
	}
	return rec(y + dy[d],x + dx[d]);
}


int main(void){
	int h, w;
	while(true){
		scanf("%d%d",&h,&w);
		getchar();
		if(h == 0 && w == 0){
			break;
		}
		for(int i = 0;i < h;i++){
			scanf("%s",&mp[i]);
		}
		printf("%s",rec(0,0));
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdio>
#define MAX_N 105

using namespace std;
int n,h,w;
int area[MAX_N][MAX_N];
string s[MAX_N];

void move(int h,int w){
	if(area[h][w]==1){
		cout << "LOOP" << endl;
		return;
	}
	area[h][w]=1;
	
	switch(s[h][w]){

		case'>':
		move(h,w+1);
		return;
		break;

		case'<':
		move(h,w-1);
		return;
		break;

		case'v':
		move(h+1,w);
		return;
		break;

		case'^':
		move(h-1,w);
		return;
		break;

		case'.':
		cout << w<< " "<<h<<endl;
		return;
		break;
	}
	return;
}

int main(){
	while(1){
		cin >> h >> w;
		if(h==0&&w==0)break;

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

		for(int i=0;i<h;i++){
			cin >> s[i];
		}
		move(0,0);

	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
const int N=101;
string G[N];
bitset<N> vis[N];
int n,m;
signed main(void){
	ios::sync_with_stdio(false);
	while(cin>>n>>m&&n&&m){
		//getchar();
		for(int i=0;i<n;i++)
				cin>>G[i];
		int x=0,y=0;
		for(int i=0;i<n;i++)
			vis[i].reset();
		while(true){
			if(vis[x][y]){
				cout<<"LOOP"<<endl;	
				break;
			}
			else if(G[x][y]=='.'){
				cout<<y<<" "<<x<<endl;
				break;	
			}
			vis[x][y]=true;
			switch(G[x][y]){
				case('>'):y++;break;
				case('<'):y--;break;
				case('^'):x--;break;
				case('v'):x++;break;
			}
		}
	}
}