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 <stdio.h>
 
int main(void)
{
    char m[102][102];
 
    while(1)
    {
        int h,w,x,y;
        scanf("%d%d",&h,&w);
        if(h==0&&w==0)return 0;
        for(y=0;y<h;y++)
            scanf("%s",m[y]);
        x=0;y=0;
        for(;;)
        {
            h=m[y][x];m[y][x]='!';
            if(h=='!')
            {
                puts("LOOP");
                break;
            }
            else if(h=='v') y++;
            else if(h=='^') y--;
            else if(h=='>') x++;
            else if(h=='<') x--;
            else
            {
                printf("%d %d\n",x,y);
                break;
            }
        }
    }
    return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
void put(int,int);
int h,w;
int x,y;
int flag=0;
char tile[1111][1111];
int main(){
  while(1){
    cin >> h >> w;
    if(h==0 && w==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> tile[i][j];
      }
    }
    put(0,0);
    if(flag==1){
      cout << y << ' ' << x << endl;
    }
    if(flag==2){
      cout << "LOOP" << endl;
    }
  }
}

void put(int a,int b){
  
  if(tile[a][b]=='.'){
    x=a;
    y=b;
    flag=1;
    return;
  }
  if(tile[a][b]==-1){
    flag=2;
    return;
  }
  if(tile[a][b]=='>'){
    tile[a][b]=-1;
    put(a,b+1);
  }
  if(tile[a][b]=='<'){
    tile[a][b]=-1;
    put(a,b-1);
  }
  if(tile[a][b]=='^'){
    tile[a][b]=-1;
    put(a-1,b);
  }
  if(tile[a][b]=='v'){
    tile[a][b]=-1;
    put(a+1,b);
  }
  return;
}

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

int main(){
	int a,b,field[100][100],x,y,loop;
	char c[100][100];
	while (1){
		loop = 0;
		x = 0;
		y = 0;
		for (int i = 0; i < 100; i++){
			for (int j = 0; j < 100; j++) field[i][j] = 0;
		}
		cin >> a >> b;
		if (!a && !b) break;
		getchar();
		for (int i = 0; i < a; i++){
			for (int j = 0; j < b; j++){
				c[i][j] = getchar();
			}
			getchar();
		}
		while (c[x][y] != '.'){
			if (field[x][y]) {
				loop = 1;
				break;
			}
			field[x][y] = 1;
			if (c[x][y] == '>') y++;
			if (c[x][y] == '^') x--;
			if (c[x][y] == '<') y--;
			if (c[x][y] == 'v') x++;
		}
		if (loop) cout << "LOOP" << endl;
		else cout << y << " " << x << endl;
	}
	return 0;
}

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

char tile[150][150];
bool flag[150][150];

int solve(int x,int y){
	if(flag[x][y]) return -1;
	int ans;
	
	flag[x][y]=true;
	switch(tile[x][y]){
	case '>':
		ans=solve(x+1,y);
		break;
	case '<':
		ans=solve(x-1,y);
		break;
	case 'v':
		ans=solve(x,y+1);
		break;
	case '^':
		ans=solve(x,y-1);
		break;
	case '.':
		ans=x*1000+y;
		break;
	default:
		break;
	}
	return ans;
}

int main(){
	int W,H,ans;

	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>>tile[j][i];
				flag[j][i]=false;
			}
		}
		
		if((ans=solve(0,0))==-1) cout<<"LOOP"<<endl;
		else cout<<ans/1000<<" "<<ans%1000<<endl;
	}
	
	return 0;
}

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

char board[100][100];
bool hasArrived[100][100];

int main() {
	int h, w;
	while (std::cin >> h >> w, h + w != 0) {
		for (int y = 0; y < h; ++y)
			for (int x = 0; x < w; ++x)
				std::cin >> board[x][y];

		int px = 0, py = 0;
		while (true) {
			if (hasArrived[px][py]) {
				std::cout << "LOOP" << std::endl;
				break;
			}

			hasArrived[px][py] = true;

			if (board[px][py] == '.') {
				std::cout << px << " " << py << std::endl;
				break;
			}
			
			if (board[px][py] == '>')
				++px;
			else if (board[px][py] == '<')
				--px;
			else if (board[px][py] == 'v')
				++py;
			else if (board[px][py] == '^')
				--py;
		}

		std::memset(board, 0, sizeof(board));
	}
}

C++: #include<iostream>

using namespace std;
int H, W;
int x = 0, y = 0;
int rog[100][100];
bool check(){
	if (rog[x][y] == 0){
		cout << "LOOP" << endl;
		return true;
	}
	else{
		return false;
	}
}
int main(){
	char map[100][100];

	while (cin >> H >> W,W+H){

		int x = 0, y = 0;
		map[100][100] = {};
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> map[i][j];
				rog[i][j] = 1;
			}
		}
		while (1){
			if (map[x][y] == '>'){
				x++;
				if (check() == true){ break; }
			}
			else if(map[x][y]=='v'){
				y--;
				if (check() == true){ break; }
			}
			else if (map[x][y] == '<'){
				x--;
				if (check() == true){ break; }
			}
			else if (map[x][y] == '^'){
				y++;
				if (check() == true){ break; }
			}
			else {
				cout << x << " " << y << endl;
				break;
			}
			
			rog[x][y] = 0;

		}
	}
	return 0;
}

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