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;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int H,W;
int x,y,flg;
string str;
int t[200][200];
void compute(){
  int a;
  if(t[y][x]==-1)return;
  if(t[y][x]==-2)flg=1;
  else {
    a=t[y][x];
    t[y][x]=-2;
    y=y+dy[a];
    x=x+dx[a];
    compute();
  }
}
int main(){
  while(cin>>H>>W){
    if(H==0&&W==0)break;
    for(int i=0;i<H;i++){
      cin>>str;
      for(int j=0;j<W;j++){
	if(str[j]=='^')t[i][j]=0;
	else if(str[j]=='>')t[i][j]=1;
	else if(str[j]=='v')t[i][j]=2;
	else if(str[j]=='<')t[i][j]=3;
	else t[i][j]=-1;
      }
    }
    x=y=flg=0;
    compute();
    if(flg)cout<<"LOOP"<<endl;
    else cout<<x<<' '<<y<<endl;
  }
  return 0;
}

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

int h, w;
char tile[100][100];
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
std::string arrows = "^>v<";

int main()
{
	while( std::cin >> h >> w, h | w )
	{
		for( int i = 0; i != h; ++i )
			for( int j = 0; j != w; ++j )
				std::cin >> tile[i][j];

		int x = 0, y = 0;
		while( true )
		{
			if( tile[y][x] == '-' )
			{
				std::cout << "LOOP" << std::endl;
				break;
			}
			else if( tile[y][x] != '.' )
			{
				int i = arrows.find( tile[y][x] );
				tile[y][x] = '-';
				x += dx[i]; y += dy[i];
			}
			else
			{
				std::cout << x << " " << y << std::endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  while(1){
    int h,w;
    cin>>h>>w;
    if(h==0 && w==0)break;
    char v[100][100];
    rep(i,h)scanf("\n%s",v[i]);
    int used[100][100]={};
    i=0;j=0;
    bool ans=true;
    while(1){
      if(used[i][j]){
        ans=false;
        break;
      }
      used[i][j]++;
      if(v[i][j]=='>')j++;
      else if(v[i][j]=='<')j--;
      else if(v[i][j]=='^')i--;
      else if(v[i][j]=='v')i++;
      else break;
    }
    if(ans)cout<<j<<" "<<i<<endl;
    else cout<<"LOOP"<<endl;
  }
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
char a[100][101];
int h,w;
 
int main() {
        while(1){
     cin>>h>>w;
     bool flag=true;
     if(!h&&!w)break;
     for(int i=0;i<h;i++){
         scanf("%s",a[i]);
     }
     int x=0,y=0;
     for(int i=0;i<h*w+1;i++){
         if(a[y][x]=='>')x++;
         if(a[y][x]=='<')x--;
         if(a[y][x]=='^')y--;
         if(a[y][x]=='v')y++;
         if(i==h*w&&a[y][x]!='.')flag=false;
     }
     if(flag)cout<<x<<" "<<y<<endl;
     else cout<<"LOOP"<<endl;
        }
        return 0;
}

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

#define max 100
char map[100][100];
bool visited[100][100];

int main(void){

	while( 1 ) {
		int pos[] = {0, 0};
		int w, h;
		cin >> h >> w;
		if( !(w|h) ) break;

		for(int i = 0; i < max * max; i++)
			visited[ i / max ][ i % max ] = false;
		for(int i = 0; i < h; i++)
			cin >> map[i];

		while( !(visited[ pos[0] ][ pos[1] ] == true || map[ pos[0] ][ pos[1] ] == '.') ) {
			visited[ pos[0] ][ pos[1] ] = true;
			switch( map[ pos[0] ][ pos[1] ] ) {
				case '>':
					pos[1] ++;
					break;
				case '<':
					pos[1] --;
					break;
				case '^':
					pos[0] --;
					break;
				case 'v':
					pos[0] ++;
					break;
			}
		}

		if( visited[ pos[0] ][ pos[1] ] == true )
			cout << "LOOP" << endl;
		else
			cout << pos[1] << " " << pos[0] << endl;

	}

	return 0;
}

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

int x, y, d, HW, H, W;
string input[10];
bool orLoop[10][10];

bool loop(int a, int b){
	if(orLoop[b][a]){
		return true;
	}
	char i = input[b][a];
	if(i=='>'){
		orLoop[b][a] = true;
		loop(a + 1, b);
	}
	else if(i=='v'){
		orLoop[b][a] = true;
		loop(a, b + 1);
	}
	else if(i=='<'){
		orLoop[b][a] = true;
		loop(a - 1, b);
	}
	else if(i=='^'){
		orLoop[b][a] = true;
		loop(a, b - 1);
	}
	else{
		x = a;
		y = b;
		return false;
	}
}

int main(){
	while(cin >> H >> W){
		if (H == 0 && W == 0) { break; }
		else { HW = H*W + 2; }

		for (int i = 0; i < 10;i++){
			for (int j = 0; j < 10;j++){
				orLoop[i][j] = false;
			}
		}
			for (int i = 0; i < H; i++)
			{
				cin >> input[i];
			}
		if(loop(0, 0)){
			cout << "LOOP" << endl;
		}
		else{
			cout << x << " " << y << endl;
		}
	}
	return 0;
}

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\n",rec(0,0));
	}
	return 0;
}

C++: #include <iostream>

enum struct Panel { none, up, down, right, left };

int main() {
    int h, w;
    while (std::cin >> h >> w && h != 0 && w != 0) {
        std::cin.ignore();

        auto room = new std::pair<Panel, bool>[h * w]();
        std::string s;
        for (int i = 0; i < h; i++) {
            std::getline(std::cin, s);
            for (int j = 0; j < w; j++) {
                switch (s[j]) {
                    case '.': room[i * w + j].first = Panel::none; break;
                    case '^': room[i * w + j].first = Panel::up; break;
                    case 'v': room[i * w + j].first = Panel::down; break;
                    case '>': room[i * w + j].first = Panel::right; break;
                    case '<': room[i * w + j].first = Panel::left; break;
                    default: return EXIT_FAILURE;
                }
            }
        }

        int x = 0, y = 0;
        [&]() {
            while (true) {
                if (room[y * w + x].second) {
                    std::cout << "LOOP";
                    break;
                }
                room[y * w + x].second = true;
                switch (room[y * w + x].first) {
                    case Panel::up: y--; break;
                    case Panel::down: y++; break;
                    case Panel::right: x++; break;
                    case Panel::left: x--; break;
                    case Panel::none: std::cout << x << ' ' << y; return;
                }
            }
        }();
        std::cout << std::endl;
    }
}