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

#define MAX 10

int main(void)
{
  int H, W;
  char tile[MAX][MAX];

  while (1) {
    
    int x = 0, y = 0;

    for(int i = 0 ; i < MAX ; i++) {
      for(int j = 0 ; j < MAX ; j++) {
	tile[i][j] = '.';
      }
    }
    
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    
    for(int i = 0 ; i < H ; i++) {
      for(int j = 0 ; j < W ; j++) {
	cin >> tile[i][j];
      }
    }
    
    int cal=0, sum=0;
    cal = H * W;

    //for(int i = 0 ; i < H ; i++) {
    //for(int j = 0 ; j < W ; j++) {
    while(tile[x][y] != '.') {
      if(tile[x][y] == '>') y++, sum++; 
      else if(tile[x][y] == '<') y--, sum++;
      else if(tile[x][y] == '^') x--, sum++;
      else if(tile[x][y] == 'v') x++, sum++;
      if(sum > cal) break;
      //cout << "x = " << x << endl << "y = " << y << endl;
    }
    if(sum <= cal) cout << y << ' ' << x << endl;
    else cout << "LOOP" << endl;
  }
  return 0;
}

C++: // 2011/01/07 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int W, H;
		cin >> W >> H;
		if(W==0&&H==0)
			break;

		char til[101][101];
		for(int i=0; i<H; i++)
			for(int j=0; j<W; j++){
				char tmp;
				do{
					cin >> tmp;
				}while(tmp=='\n');
				til[i][j] = tmp;
		}

		bool flg[101][101];
		for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
				flg[i][j] = false;

		int x = 0;
		int y = 0;
		while(true){
			if(flg[y][x]){
				cout << "LOOP" << endl;
				break;
			}

			flg[y][x] = true;

			if(til[y][x]=='>')
				x++;
			else if(til[y][x]=='<')
				x--;
			else if(til[y][x]=='v')
				y++;
			else if(til[y][x]=='^')
				y--;
			else{
				cout << x << ' ' << y << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<cstring>
using namespace std;
int W,H;
char fie[102][102];
int cost[102][102];
char df[]={'>','v','<','^'};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
  while(1){
    cin >> W >> H;
    memset(fie,-1,sizeof(fie));
    memset(cost,0,sizeof(cost));
    if(W==0 && H==0) break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> fie[j][i];
      }
    }
    int x=0,y=0;
    bool f=false;
    cost[x][y]=1;
    while(fie[x][y]!='.'){
      for(int i=0;i<4;i++){
	
	if(fie[x][y]==df[i]){
	  x+=dx[i];
	  y+=dy[i];
	}
      }
      if(cost[x][y]){
	f=true;
	break;
      }
      cost[x][y]=1;
    }
    if(!f) printf("%d %d\n",x,y);
    else puts("LOOP");
  }
}

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

int H,W;

int main(void)
{
	while(cin >> H >> W, H && W){
		char room[101][102] = {};
		bool  fd[101][101] = {};
		for(int i = 0; i < H; i++)
			cin >> room[i];

		int x = 0, y = 0;
		while(room[y][x] != '.' && !fd[y][x]){
			fd[y][x] = true;

			switch(room[y][x]){
				case '>':
					x++;
					break;
				case '^':
					y--;
					break;
				case '<':
					x--;
					break;
				case 'v':
					y++;
					break;
			}
		}
		if(room[y][x] == '.')
			cout << x << ' ' << y << endl;
		else
			cout << "LOOP" << endl;

	}


	return 0;
}

C++: #include<iostream>

void move(int, int);

char tiles[100][100];
bool mem[100][100];

int main()
{
  int H, W;
  while(true)
  {
    std::cin >> H >> W;
    if(!H && !W)
      break;

    for(int i = 0; i < H; i++)
      std::cin >> tiles[i];
    
    move(0, 0);
  }
  return 0;
}

void move(int x, int y)
{
  if(mem[y][x])
  {
    std::cout << "LOOP" << std::endl;
    return;
  }

  mem[y][x] = true;

  switch(tiles[y][x])
  {
    case '<':
      move(x - 1, y);
      return;
    case '>':
      move(x + 1, y);
      return;
    case '^':
      move(x, y - 1);
      return;
    case 'v':
      move(x, y + 1);
      return;
    case '.':
      std::cout << x << " " << y << std::endl;
      return;
  }
}

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

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

C++: #include<cstdio>
#include<cstring>


int main()
{
	int w,k,hyou[100][100],i,j,check[100],l=0;
	memset(check,0,100*sizeof(int));
	char a;
	while(1)
	{
		scanf("%d%d",&w,&k);
		if(w==0)
			break;
		scanf("%c",&a);
		for(i=0;i<w;i++)
		{
			for(j=0;j<=k;j++)
			{
				scanf("%c",&a);
				if(a=='>')
					hyou[i][j]=1;
				else	if(a=='<')
					hyou[i][j]=2;
				else if(a=='v')
					hyou[i][j]=3;
				else if(a=='^')
					hyou[i][j]=4;
				else if(a=='.')
					hyou[i][j]=0;
				else 
					hyou[i][j]=6;
			}
			
			
		}
		i=0;
		j=0;
		while(hyou[i][j]!=5&&hyou[i][j]!=0)
		{
			switch(hyou[i][j])
			{
			case 1:
				hyou[i][j]=5;
				j++;
				break;
			case 2:
				hyou[i][j]=5;
				j--;
				break;
			case 3:
				hyou[i][j]=5;
				i++;
				break;
			case 4:
				hyou[i][j]=5;
				i--;
				break;
			case 0:
				check[l]=i*10+j;
				break;
			case 5:
				check[l]=0;
				break;
			}
		}
		if(hyou[i][j]==0)
			check[l]=i*10+j;
		l++;
	}
	for(i=0;i<l;i++)
	{
		if(check[i]==0)
			printf("LOOP\n");
		else
			printf("%d %d\n",check[i]%10,check[i]/10);
	}
	return 0;
}

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

int h,w;
char t[102][102];

int main(void){
	while(cin>>h>>w,h||w){
		for(int i=0;i<h;i++){
			cin>>t[i];
		}
		int i=0,j=0;
		while(t[i][j] != '.' && t[i][j] != 'x'){
			int ti = i;
			int tj = j;
			if(t[i][j] == '>')
				j++;
			else if(t[i][j] == '<')
				j--;
			else if(t[i][j] == 'v')
				i++;
			else
				i--;

			t[ti][tj] = 'x';
		}
		if(t[i][j] == 'x'){
			cout<<"LOOP\n";
		}
		else{
			cout<<j<<" "<<i<<endl;
		}
	}

	return 0;
}