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 <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	enum { NOTHING, EAST, WEST, NORTH, SOUTH };
	string str = "";

	while (getline (cin, str ) ){

		int h, w;
		stringstream ssn(str);
		ssn >> h >> w;

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

		vector<vector <int> > m (h, vector <int> (w, 0 ) );
		vector<vector <bool> > v (h, vector <bool> (w, false ) );
		int i,j;

		for (i = 0; i < h; ++i ){

			getline (cin, str );

			for (j = 0; j < w; ++j ){
				char c = str[j];
				switch (c){
					case '.': m[i][j] = NOTHING; break;
					case '^': m[i][j] = NORTH; break;
					case '>': m[i][j] = EAST; break;
					case 'v': m[i][j] = SOUTH; break;
					case '<': m[i][j] = WEST; break;
				} // end switch
			} // end for
		} // end for

		int currx = 0;
		int curry = 0;

		while (!v[curry][currx] && m[curry][currx] != NOTHING ){

 			v[curry][currx] = true;
			int d = m[curry][currx];

			switch (d){
				case NORTH: --curry; break;
				case SOUTH: ++curry; break;
				case EAST:  ++currx; break;
				case WEST:  --currx; break;
			} // end switch
		} // end while

		if (!v[curry][currx]){
			cout << currx << ' ' << curry << endl;
		}else{
			cout << "LOOP" << endl;
		} // end if

	} // end loop

	return 0;
}

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

int main(){
	int y, x, i, j;
	bool stop;
	string str;
	while(true){
		cin>>y>>x;if(y==0 &&x==0) break;
		vector<vector<pair<char, bool> > > field(y, vector<pair<char, bool> >(x));
		for(i=0;i<y;i++){
			cin>>str;
			for(j=0;j<x;j++){
				field[i][j].first = str[j];
				field[i][j].second = false;
			}
		}
		stop=false;
		j = i = 0;
		while(true){
			if(stop==true){
				cout<<j<<" "<<i<<endl;
				break;
			}else if(field[i][j].second == true){
				cout<<"LOOP\n";
				break;
			}
			field[i][j].second = true;
			switch(field[i][j].first){
				case '.': stop=true; break;
				case '>': j++; break;
				case 'v': i++; break;
				case '<': j--; break;
				case '^': i--; break;
			}
		}
	}
	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<iostream>
#include<string>
#include<cstring>
using namespace std;

int main(void){
  int w,h;
  while(cin>>h>>w,h){
    string f[h];
    for(int i=0;i<h;i++){
      cin>>f[i];
    }	
    int x,y;
    x=y=0;
    while(true){
      if(f[y][x]=='p'){
	cout<<"LOOP"<<endl;
	break;
      }
      if(f[y][x]=='.'){
	cout<<x<<" "<<y<<endl;
	break;
      }
      if(f[y][x]=='>') {
	f[y][x]='p';x+=1;}
      if(f[y][x]=='<') {
	f[y][x]='p'; x-=1;}
      if(f[y][x]=='^') {
	f[y][x]='p'; y-=1;}
      if(f[y][x]=='v') {
	f[y][x]='p'; y+=1;}
    }
	
    	
  }
	
}

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

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

bool loop(int a, int b){
	if(orLoop[b][a]){
		return true;
	}
	char i = input[b][a];
	if(i=='>'){
		orLoop[b][a] = true;
		if(loop(a + 1, b)){
			return true;
		}
		else
			return false;
	}
	else if(i=='v'){
		orLoop[b][a] = true;
		if(loop(a, b + 1)){
			return true;
		}
		else
			return false;
	}
	else if(i=='<'){
		orLoop[b][a] = true;
		if(loop(a - 1, b)){
			return true;
		}
		else
			return false;
	}
	else if(i=='^'){
		orLoop[b][a] = true;
		if(loop(a, b - 1)){
			return true;
		}
		else
			return false;
	}
	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<iostream>
#include<cstdio>
#include<string>
using namespace std;
int h,w;
string ss[100];
bool x[100][100];
int ans1=0,ans2=0;
bool ans=true;
bool f(){
	while(true){
		if(ss[ans1][ans2]=='.')return true;
		else if(!x[ans1][ans2])return false;
		else if(ss[ans1][ans2]=='>'){
			x[ans1][ans2]=false;
			ans2++;
			f();
		}
		else if(ss[ans1][ans2]=='<'){
			x[ans1][ans2]=false;
			ans2--;
			f();
		}
		else if(ss[ans1][ans2]=='v'){
			x[ans1][ans2]=false;
			ans1++;
			f();
		}
		else{
			x[ans1][ans2]=false;
			ans1--;
			f();
		}
	}
}
int main()
{
	while(true){
		scanf("%d%d",&h,&w);
		if(h==0&&w==0)return 0;
		for(int i=0;i<h;i++)cin >> ss[i];
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)x[i][j]=true;
		ans1=0,ans2=0;
		ans=true;

		if(f()){
		    cout << ans1 << " " << ans2 << "\n";
		}
		else cout << "LOOP" << "\n";
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	struct POINT {int x, y;} p;
	int w, h, i, j, c;
	char f[100][100];
	bool b;
	while (cin >> w >> h)
	{
		if (w == 0 && h == 0) break;
		p.x = p.y = 0;
		b = false;
		c = 0;
		for (i = 0; i < w; i++)
			for (j = 0; j < h; j++)
				cin >> f[i][j];
		while (c <= w*h)
		{
			switch (f[p.y][p.x])
			{
			case '>':
				p.x++;
				break;
			case '^':
				p.y--;
				break;
			case '<':
				p.x--;
				break;
			case 'v':
				p.y++;
				break;
			default:
				cout << p.x << " " << p.y << endl;
				b = true;
				break;
			}
			if (b) break;
			c++;
		}
		if (!b) cout << "LOOP" << endl;
	}
}