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>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

using namespace std;

#define all(c) c.begin(),c.end()
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& val){
    os << "[ ";
    for(typename vector<T>::const_iterator it=val.begin();
        it != val.end();++it){
        os << *it << " ";
    }
    os << "]";
    return os;
}
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};

inline int mc(char c){
// '>' (大なり記号): 東向きの矢印が書かれたタイル
// '<' (小なり記号): 西向きの矢印が書かれたタイル
// '^' (べき記号) : 北向きの矢印が書かれたタイル
// 'v' (小文字ブイ): 南向きの矢印が書かれたタイル
// '.' (ピリオド) : 何も書かれていないタイル
    switch(c){
    case '>':
        return 0;
    case '<':
        return 2;
    case '^':
        return 1;
    case 'v':
        return 3;
    case '.':
        return -1;
    }
    return -1;
}

string solve(vector<string> field){

    int W = field[0].size();
    int H = field.size();
    vector<vector<char> > alr(H,vector<char>(W,false));

    int nx = 0;
    int ny = 0;
    while(mc(field[ny][nx]) != -1){
        if(alr[ny][nx]){
            return "LOOP";
        }
        alr[ny][nx] = true;
        int d = mc(field[ny][nx]);
        ny += dy[d];
        nx += dx[d];
    }
    stringstream ss;
    ss << nx << " " << ny;
    return ss.str();
}
int main(){
    while(true){
        int W,H;
        cin >> H >> W;
        if(W == 0 and H == 0) break;
        vector<string> field(H);
        for(int i=0;i<H;i++){
            cin >> field[i];
        }
        cout << solve(field) << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<stdlib.h>

int magicalTiles();

void listen_matrixSize(int &,int &);
void listen_matrix(std::vector<std::string> &,const int);
void calc_goalPosition(std::vector<std::string> &,int &,int &,const int,const int);
const int LOOPFLAG=999999;
bool is_loop(const int);

//--------------------------------main------------------------------------

int main()
{
	while(magicalTiles());
	
	return 0;
}

int magicalTiles()
{
	using namespace std;
	int height,width;
	listen_matrixSize(height,width);
	if(!height && !width)
	{
		return 0;
	}
	
	vector<string> matrix;
	listen_matrix(matrix,height);
	
	int goal_h,goal_w;
	if(calc_goalPosition(matrix,goal_h,goal_w,height,width),is_loop(goal_h))
	{
		cout<<"LOOP"<<endl;
	}
	else
	{
		cout<<goal_w<<" "<<goal_h<<endl;
	}
	
	return 1;
}

//-----------------------------------------------------------------------------

void listen_matrixSize(int &height,int &width)
{
	using namespace std;
	
	cin>>height>>width;
}

void listen_matrix(std::vector<std::string> &matrix,const int height)
{
	using namespace std;
	
	string tmp_tile;
	for(int loop_h=0;loop_h<height;loop_h++)
	{
		cin>>tmp_tile;
		matrix.push_back(tmp_tile);
	}
}

void calc_goalPosition(std::vector<std::string> &matrix,int &goal_h,int &goal_w,const int height,const int width)
{
	using namespace std;
	
	int reachedPosition[height][width];
	for(int init_h=0;init_h<height;init_h++)
	{
		for(int init_w=0;init_w<width;init_w++)
		{
			reachedPosition[init_h][init_w]=0;
		}
	}
	
	int current_h=0,current_w=0;
	for(;1;)
	{
		if(!reachedPosition[current_h][current_w])
		{
			reachedPosition[current_h][current_w]=1;
		}
		else
		{
			goal_h=LOOPFLAG;
			return;
		}
		switch(matrix[current_h].at(current_w))
		{
		case '^':
			current_h--;
			break;
		case 'v':
			current_h++;
			break;
		case '<':
			current_w--;
			break;
		case '>':
			current_w++;
			break;
		case '.':
			goal_h=current_h;
			goal_w=current_w;
			return;
		default:
			cout<<"unknown tile inputed"<<endl;
			abort();
		}
	}
}

bool is_loop(const int goal_h)
{
	if(goal_h==LOOPFLAG)
	{
		return true;
	}
	else
	{
		return false;
	}
}

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

using namespace std;

int main(){
	char t[100][100];
	char temp;
	int H,W,i,j,loopch;
	
	while(scanf("%d %d",&H,&W)){
		if(H==0&&W==0)
		break;
		string s;
		cin.ignore();
		for(i=0;i<H;i++){
			getline(cin,s);
			for(j=0;j<W;j++){
				t[i][j] = s[j];
			}
		}
		i=0;
		j=0;
		loopch=0;
		while(t[i][j]!='.'){
			if(t[i][j]=='>'){
				t[i][j]='*';
				j++;
			}
			else if(t[i][j]=='<'){
				t[i][j]='*';
				j--;
			}
			else if(t[i][j]=='^'){
				t[i][j]='*';
				i--;
			}
			else if(t[i][j]=='v'){
				t[i][j]='*';
				i++;
			}
			else if(t[i][j]=='*'){
				loopch=1;
				break;
			}
		}
		if(loopch!=1)
		printf("%d %d\n",j,i);
		else
		printf("LOOP\n");
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  while(cin>>H>>W,H+W!=0){
    string tile[H];
    for(int i=0;i<H;i++)
      cin>>tile[i];
    if(tile[0][0]=='.'){
      cout<<"0 0"<<endl;
      continue;
    }
    int i=0;
    pair<int,int> now=make_pair(0,0);
    while(i!=20001){
      i++;
      if(i==20000)
	cout<<"LOOP"<<endl;
      if(tile[now.first][now.second]=='.'){
	cout<<now.second<<" "<<now.first<<endl;
	break;
      }else if(tile[now.first][now.second]=='>')
	now.second++;
      else if(tile[now.first][now.second]=='<')
	now.second--;
      else if(tile[now.first][now.second]=='v')
	now.first++;
      else if(tile[now.first][now.second]=='^')
	now.first--;
    }
  }
  return 0;
}

C++: #include<iostream>

void move(int, int);

char tiles[101][101];
bool mem[101][101];

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

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<stdio.h>

int main(){

char x[102]={};
char n[102][102]={};

int w,h;

while(1){

scanf("%d %d",&h,&w);
if(h==0&&w==0)break;
bool f[102][102]={};
for(int i=0;i<h;i++)
{scanf("%s",&x);
for(int j=0;j<=w;j++)
{	n[i][j]=x[j];f[i][j]=true;}
}


int a=0,b=0;
while(f[b][a]!=false){
if(n[b][a]=='>'){a++;f[b][a-1]=false;}
else if(n[b][a]=='<'){a--;f[b][a+1]=false;}
else if(n[b][a]=='v'){b++;f[b-1][a]=false;}
else if(n[b][a]=='^'){b--;f[b+1][a]=false;}
else if(n[b][a]=='.'){break;}
}

if(f[b][a]==false)printf("LOOP\n");
else printf("%d %d\n",a,b);
}
return 0;
}