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>

int main(int argc, char **argv)
{
	int h, w;
	int x = 0, y = 0;
	char tiles[100][100];
	bool throughed[100][100] = {};
	bool loop = false;
	bool end = false;
	while(std::cin >> h >> w, h+w != 0){
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				std::cin >> tiles[j][i];
			}
		}
		while(true){
			if(throughed[x][y]){
				loop = true;
				break;
			}
			throughed[x][y] = true;
			switch(tiles[x][y]){
				case '.':
					end = true;
					break;
				case '^':
					y--;
					break;
				case 'v':
					y++;
					break;
				case '<':
					x--;
					break;
				case '>':
					x++;
					break;
			}
			if(end){
				break;
			}
		}
		if(loop){
			std::cout << "LOOP" << std::endl;
		}else{
			std::cout << x << " " << y << std::endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

int h,w;
vector<vector<char> > field;

int main(){
	while(1){
		cin>>h>>w;
		if(!h&&!w) break;
		field=vector<vector<char> >(h,vector<char>(w));
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>field[i][j];
			}
		}
		int H=0,W=0;
		bool loop=0;
		while(field[H][W]!='.'){
			if(field[H][W]=='!'){
				cout<<"LOOP"<<endl;
				loop=1;
				break;
			}
			char tmp=field[H][W];
			field[H][W]='!';
			if(tmp=='>') W++;
			else if(tmp=='<') W--;
			else if(tmp=='^') H--;
			else H++;
		}
		if(!loop) cout<<W<<' '<<H<<endl;
	}
}

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];
   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(map[x][y]=='>') 
       {
         x++;
         step++;
         //cout<<">"<<" ";                      
       }        
       if(map[x][y]=='<')
       {
         x--;
         step++;   
         //cout<<"<"<<" ";                   
       }
       if(map[x][y]=='v')
       {
         y++;
         step++;         
         //cout<<"v"<<" ";             
       }
       if(map[x][y]=='^')
       {
         y--;
         step++;         
         //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 <stdio.h>

int main(void)
{
	int w, h, i, j;
	char dummy;
	char a[100][100] = {0};

	scanf("%d %d", &w, &h);

	while ((w != 0) && (h != 0))
	{
		scanf("%c", &dummy);
		for (j = 0; j < h; j++)
			gets(a[j]);

		i = 0;
		j = 0;
		while (1)
		{
			if (a[j][i] == 'L')
			{
				printf("LOOP\n");
				break;
			}
			a[j][i] = 'L';
			
			if (a[j][i] == '>')
				i++;
			else if (a[j][i] == '<')
				i--;
			else if (a[j][i] == '^')
				j--;
			else if (a[j][i] == 'v')
				j++;
			else if (a[j][i] == '.')
			{
				printf("%d %d\n", i, j);
				break;
			}
		}

		scanf("%d %d", &w, &h);
	}

	return 0;
}

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

using namespace std;

struct RECORD{
  int x;
  int y;
};

int main(){
  int i, j, k, l, n, w, h, loop;
  string tile[100];
  RECORD one;
  vector<RECORD> data;

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

    for(i=0; i<w; ++i)
      cin >> tile[i];

    i = 0;
    j = 0;
    loop = 0;
    while(1){
      k = i;
      l = j;

      if(tile[i][j] == '>'){
	++j;
      }else if(tile[i][j] == '<'){
	--j;
      }else if(tile[i][j] == '^'){
	--i;
      }else if(tile[i][j] == 'v'){
	++i;
      }else if(tile[i][j] == '.'){
	cout << j << " " << i << endl;
	break;
      }

      if(tile[i][j] != tile[k][l]){
	for(n=0; n<data.size(); ++n){
	  if(data[n].x == i && data[n].y == j){
	    cout << "LOOP" << endl;
	    loop = 1;
	    break;
	  }
	}

	if(loop == 1) break;
	one.x = i;
	one.y = j;
	data.push_back(one);
      }
    }

    data.clear();
  }

  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define ITER( c ) __typeof( c ).begin()
#define REP( i, m, n ) for ( int i = m; i < n; i++ )
#define UREP( i, m, n ) for ( unsigned int i = m; i < n; i++ )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) c.begin(), c.end()
#define PB( n ) push_back( n );
#define MP( a, b ) make_pair( a, b )
#define fst first
#define snd second

int main()
{
	while ( true )
	{
		int h, w;
		cin >> h >> w;
		cin.ignore( 1 );

		if ( h == 0 && w == 0 )
		{
			break;
		}

		vector<string> field;

		REP( i, 0, h )
		{
			string buffer;
			cin >> buffer;
			field.PB( buffer );
		}

		pair<int,int> current = MP( 0, 0 );
		set< pair<int,int> > visited;

		while ( true )
		{
			if ( field[ current.fst ][ current.snd ] == '.' )
			{
				cout << current.snd << ' ' << current.fst << endl;
				break;
			}

			if ( visited.find( current ) != visited.end() )
			{
				cout << "LOOP" << endl;
				break;
			}

			visited.insert( current );

			switch ( field[ current.fst ][ current.snd ] )
			{
			case '>':
				current.snd++;
				break;
			case '<':
				current.snd--;
				break;
			case '^':
				current.fst--;
				break;
			case 'v':
				current.fst++;
				break;
			}

		}
	}

	return 0;
}