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 h, w;
char t[110][110];

int main(){
  while(cin >> h >> w, h || w){
    for(int i = 0; i < h; i++){
      cin >> t[i];
    }

    int x = 0, y = 0;

    while(true){
      //ツ止ツづ慊づ?つスツづィ, ツδ?ツプツつオツつスツづィツつオツつスツづァツ終ツ猟ケ
      if(t[y][x] == '.' || t[y][x] == 'L'){
        break;
      }

      //ツパツネツδ仰づ個津環づィツづ可暗堋督ョツつキツづゥ
      int nx = x;
      int ny = y;

      switch(t[y][x]){
        case '^': ny--; break;
        case '>': nx++; break;
        case 'v': ny++; break;
        case '<': nx--; break;
      }

      //ツ辿ツづ?つスツづ?つアツづォツづ可づ? ツ暗ウツづーツづつつッツづ?つィツつ「ツづ? ツδ?ツプツつオツつスツつアツづ?つェツづュツつゥツづゥツづヲツつ、ツづ可つキツづゥ
      t[y][x] = 'L';
      x = nx;
      y = ny;
    }

    //ツ暗ェツ度ツ辿ツづ?つスツつアツづ?つ?づゥツ渉ーツづ?終ツ猟ケツつオツづ?つ「ツつスツづァツδ?ツプ
    if(t[y][x] == 'L'){
      cout << "LOOP\n";
    }
    //'.'ツづ?終ツづュツづ?づ?つ「ツつスツづァツ止ツづ慊づ?つス
    else{
      cout << x << " " << y << endl;
    }
  }
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
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<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];
   int map2[100+5][100+5]={{0}};
   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(map2[x][y]==1) 
       {
         flag=true;
         break;                  
       }
       if(map[x][y]=='>') 
       {
         x++;
         step++;
         map2[x][y]=1;
         //cout<<">"<<" ";                      
       }        
       if(map[x][y]=='<')
       {
         x--;
         step++;   
         map2[x][y]=1;
         //cout<<"<"<<" ";                   
       }
       if(map[x][y]=='v')
       {
         y++;
         step++;         
         map2[x][y]=1;
         //cout<<"v"<<" ";             
       }
       if(map[x][y]=='^')
       {
         y--;
         step++;      
         map2[x][y]=1;   
         //cout<<"^"<<" ";             
       }
       if(step>(w*h))
       {
         flag=true;
         break;            
       }
       if(map[x][y]=='.')
       {
         break;                  
       }
       if(flag) break;
     }        
     if(flag) cout<<"LOOP"<<endl;
     else cout<<x<<" "<<y<<endl;
   }
   //while(1);
   return 0;
 }

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int h,w;
  while(cin>>h>>w,h+w) {
    char ba[h][w];
    REP(y,h) {
      REP(x,w) {
        cin >> ba[x][y];
      }
    }
    int x = 0, y = 0;
    int dx[] = {0,1,0,-1};
    int dy[] = {-1,0,1,0};
    char aa[] = {'^','>','v','<'};
    map<char,int> hoge;
    REP(i,4)
      hoge[aa[i]] = i;
    int f[w][h];
    memset(f,0,sizeof(f));
    while(true) {
      if (f[x][y]) break;
      else f[x][y] = 0;
      if (ba[x][y] == '.') break;
      else {
        x += dx[hoge[ba[x][y]]];
        y += dy[hoge[ba[x][y]]];
      }
    }
    if (f[x][y]) cout << "LOOP" << endl;
    else cout << x << " " << y << endl;
  }
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
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;
    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<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;
	 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=false;
	 do{
	  if(use[x][y]){cout<<"LOOP"<<endl;break;}
	  use[x][y]=true;
	  switch(tile[x][y]){
		case '.':
		flg=true;
		cout<<x<<" "<<y;
		break;

		case '>':
		x+=1;
		break;

		case '<':
		x-=1;
		break;

		case '^':
		y-=1;
		break;

		case 'v':
		y+=1;
		break;
	  }
	 }while(flg);
	}
}

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 y=0; y<H; y++)
			for(int x=0; x<W; x++)
				cin >> til[y][x];

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

		for(int x=0, y=0; ; ){
			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 if(til[y][x]=='.'){
				cout << x << ' ' << y << endl;
				break;
			}
		}
	}

	return 0;
}