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>

std::pair<char,bool> data[101][101];

int main(){
	int w,h;
	while(std::cin>>w>>h){
		if(w==0&&h==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				std::cin>>data[i][j].first;
				data[i][j].second=false;
			}
		}
		int x=0,y=0;
		while(true){
			if(data[y][x].second){
				std::cout<<"LOOP"<<std::endl;
				break;
			}data[y][x].second=true;

			if(data[y][x].first=='^')y--;
			if(data[y][x].first=='>')x++;
			if(data[y][x].first=='v')y++;
			if(data[y][x].first=='<')x--;

			if(data[y][x].first=='.'){
				std::cout<<x<<" "<<y<<std::endl;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;
typedef pair<int, int> p;

void solve()
{
	int H, W;
	while(cin >> H >> W, H || W)
	{
		vector< vector<bool> > isVisited(H, vector<bool>(W));
		vector< vector<char> > tile(H, vector<char>(W));
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				isVisited[i][j] = false;
				cin >> tile[i][j];
			}
		}
		p pos(0, 0);
		while(true)
		{
			if(isVisited[pos.second][pos.first])
			{
				cout << "LOOP" << endl;
				break;
			}
			else
			{
				isVisited[pos.second][pos.first] = true;
				if(tile[pos.second][pos.first] == '>')
				{
					++pos.first;
				}
				else if(tile[pos.second][pos.first] == '^')
				{
					--pos.second;
				}
				else if(tile[pos.second][pos.first] == '<')
				{
					--pos.first;
				}
				else if(tile[pos.second][pos.first] == 'v')
				{
					++pos.second;
				}
				else if(tile[pos.second][pos.first] == '.')
				{
					cout << pos.first << " " << pos.second << endl;
					break;
				}
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

string map[110];
int j_map[110][110];
int* ans(int* x){
	if(j_map[x[0]][x[1]]==1){
		x[0]=x[1]=-1;
		return x;
	}else{
		j_map[x[0]][x[1]]=1;
		
		if(map[x[0]][x[1]]=='v'){
			x[0]++;
			return ans(x);
		}else if(map[x[0]][x[1]]=='<'){
			x[1]--;
			return ans(x);
		}else if(map[x[0]][x[1]]=='>'){
			x[1]++;
			return ans(x);
		}else if(map[x[0]][x[1]]=='^'){
			x[0]--;
			return ans(x);
		}else{
			return x;
		}
	}
}



int main(){
	int w,h;
	while(cin>>w,cin>>h,(w!=0)&&(h!=0)){
		for(int i=0;i<w;i++){
			cin>>map[i];
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				j_map[i][j]=0;
			}
		}
		
		int* x=(int *)malloc(sizeof(int)*2);
		x[0]=x[1]=0;
		x = ans(x);
		if(x[0]==-1){
			cout<<"LOOP"<<endl;
		}else{
			cout<<x[1]<<" "<<x[0]<<endl;
		}
	}
	
}

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


int main()
{
	int w,k,hyou[100][100],i,j,checki[100],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;
				checki[l]=j;
				break;
			case 5:
				check[l]=0;
				break;
			}
		}
		if(hyou[i][j]==0)
		{	check[l]=i;
			checki[l]=j;}
		if(hyou[i][j]==5)
			check[l]=-1;
		l++;
	}
	for(i=0;i<l;i++)
	{
		if(check[i]==-1)
			printf("LOOP\n");
		else
			printf("%d %d\n",checki[i],check[i]);
	}
	return 0;
}

C++: #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main()
{
	int N, M;
	vector<string>data;
	while (cin >> N >> M, N || M)
	{
		data.clear();
		data.resize(N);
		for (size_t i = 0; i < N; i++)
		{
			cin >> data[i];
		}
		int nowx = 0, nowy = 0;
		while (data[nowx][nowy] != '.' && data[nowx][nowy] != 1)
		{
			switch (data[nowx][nowy])
			{
				case '>':{
						data[nowx][nowy] = 0;
						nowy++;
						break;
					}
				case '<':{
						data[nowx][nowy] = 0;
						nowy--;
						break;
					}
				case '^':{
						data[nowx][nowy] = 0;
						nowx--;
						break;
					}
				case 'v':{
						data[nowx][nowy] = 0;
						nowx++;
						break;
					}
				case 0:{
						data[nowx][nowy] = 1;
						break;
					}
				default:break;
			}
		}
		if (data[nowx][nowy] == 1) cout << "LOOP" << endl;
		else cout << nowy << " " << nowx << endl;
	}
	return 0;
}

C++: /*
	0104:Magical Tiles
*/
#include	<iostream>

using namespace std;

//GV
char map[101][101];

//FN
void refmaps(void);
void start(void);

int main(void) {
	while(1) {
		int W, H;
		
		refmaps();
		
		cin >> H >> W;
		if(H == 0 && W == 0) { break; }
		
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				char c;
				cin >> c;
				map[i][j] = c;
			}
		}
		
		start();
	}
	return 0;
}

void refmaps(void) {
	for(int i = 0; i < 101; i++) {
		for(int j = 0; j < 101; j++) {
			map[i][j] = '.';
		}
	}
}

void start(void) {
	int h = 0, w = 0;
	const int vx[4] = {1, 0, -1, 0}, vy[4] = {0, 1, 0, -1};
	const char vc[4] = {'>', 'v', '<', '^'};
	
	while(1) {
		if(map[h][w] == '.') { cout << w << ' ' << h << endl; return; }
		else if(map[h][w] == 'L') { cout << "LOOP" << endl; return; }
		else {
			for(int i = 0; i < 4; i++) {
				if(map[h][w] == vc[i]) {
					map[h][w] = 'L';
					h += vy[i];		w += vx[i];
				}
			}
		}
	}
}