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>
#include <vector>

using namespace std;

typedef struct{
    int x;
    int y;
}dbint;

dbint move(char c){
    dbint mv;
    switch (c) {
        case '>':
            mv.x=1;
            mv.y=0;
            break;
        case '^':
            mv.x=0;
            mv.y=-1;
            break;
        case '<':
            mv.x=-1;
            mv.y=0;
            break;
        case 'v':
            mv.x=0;
            mv.y=1;
            break;
        default:
            mv.x=10;
            mv.y=10;
            break;
    }
    return mv;
}

int main() {
    int h,w,n=0;
    char c;
    dbint p,mv;
    vector< vector<char> > tiles;
    vector<char> temp;
    while(1){
        cin >> h >> w;
        p.x=0;p.y=0;
        if(h==0&&w==0) break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> c;
                temp.push_back(c);
            }
            tiles.push_back(temp);
            temp.clear();
        }
        while(1){
            mv=move(tiles[p.y][p.x]);
            if(mv.x>1) break;
            p.x+=mv.x;
            p.y+=mv.y;
            n++;
            if(n>h*w*10){
                n=-1;
                break;
            }
        }
        if(n>0) cout << p.x << " " << p.y << endl;
        else    cout << "LOOP" << endl;
        tiles.clear();
    }
    return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main(){
	while (true){
		char room[100][100];
		int H, W; cin >> H >> W;
		if (H == 0 && W == 0)return 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> room[i][j];
			}
		}
		pair<int, int>l;
		l.first = 0; l.second = 0;
		for (int i = 0; ; i++){
			if (i >= 100) {
				cout << "LOOP\n";
				goto Exit;
			}
			char c = room[l.first][l.second];
			if (c == '.') {
				cout << l.second << ' ' << l.first << endl;
				goto Exit;
			}
			if (c == '^')l.first--;
			else if (c == 'v')l.first++;
			else if (c == '<')l.second--;
			else if (c == '>')l.second++;
		}
	Exit:;
	}
}

C++: #include<iostream>

using namespace std;

char map[110][110];
int s_x,s_y,loop;

void serch(int x,int y)
{
	if(map[x][y]=='1')
	{
		loop=1;
		return ;
	}
	if(map[x][y]=='.')
	{
		s_x=x;
		s_y=y;
		return ;
	}
	if(map[x][y]=='>')
	{
//		cout << "x:" << x << " y:" << y <<" nowmap:" << map[x][y] << endl;
		map[x][y]='1';
		serch(x,y+1);
	}
	else if(map[x][y]=='<')
	{
//		cout << "x:" << x << " y:" << y <<" nowmap:" << map[x][y] << endl;
		map[x][y]='1';
		serch(x,y-1);
	}
	else if(map[x][y]=='v')
	{
//		cout << "x:" << x << " y:" << y <<" nowmap:" << map[x][y] << endl;
		map[x][y]='1';
		serch(x+1,y);
	}
	else if(map[x][y]=='^')
	{
//		cout << "x:" << x << " y:" << y <<" nowmap:" << map[x][y] << endl;
		map[x][y]='1';
		serch(x-1,y);
	}
	return ;
}

int main()
{
	int w,h;
	int i,j;
	
	for(;;)
	{
		loop=0;
		cin >> w >> h ;
		if(w==0 && h==0)
			break;
		for(i=0;i<w;i++)
		{
			for(j=0;j<h;j++)
			{
				cin >> map[i][j] ;
			}
		}
		
		serch(0,0);
		
		if(loop==1)
			cout << "LOOP" << endl;
		else
			cout << s_y << " " << s_x << endl;
	}
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int h, w;
	while (cin >> h >> w && (h || w)) {
		VS tile(h); vector<VB> visited(h, VB(w));
		rep(i, h)cin >> tile[i];

		PII now = mp(0, 0), ans = mp(-1, -1); bool loop = false;
		while (!loop && ans.first == -1 && ans.second == -1) {

			if (visited[now.second][now.first])loop = true;
			visited[now.second][now.first] = true;

			switch (tile[now.second][now.first]) {
			case '.':
				ans = now;
				break;
			case '>':
				now.first++;
				break;
			case '<':
				now.first--;
				break;
			case '^':
				now.second--;
				break;
			case 'v':
				now.second++;
				break;
			}

		}

		if (loop)puts("LOOP");
		else Cout2(ans.first, ans.second);
	}
}

C++: #include <iostream>
#include <string>
#include <cstdio>
#define MAX_N 105

using namespace std;
int n,h,w;
int area[MAX_N][MAX_N];;
string s[MAX_N];

void move(int h,int w){
	if(area[h][w]==1){
		cout << "LOOP" << endl;
		return;
	}
	area[h][w]=1;
	
	switch(s[h][w]){
		case'>':
		move(h,w+1);
		return;
		break;
		case'<':
		move(h,w-1);
		return;
		break;
		case'v':
		move(h+1,w);
		return;
		break;
		case'^':
		move(h-1,w);
		return;
		break;
		case'.':
		cout << w<< " "<<h<<endl;
		return;
		break;
	}
}

int main(){
	while(1){
		cin >> h >> w;
		if(h==0&&w==0)break;
		for(int i=0;i<h;i++){
			cin >> s[i];
		}
		move(0,0);

	}
	return 0;
}

C++: //51
#include<iostream>

using namespace std;

int main(){
  for(int W,H;cin>>W>>H,W|H;){
    char g[100][100];
    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
	cin>>g[y][x];
      }
    }
    int y=0,x=0;
    while(g[y][x]!='.'&&g[y][x]!='\0'){
      int ny=y+(g[y][x]=='v')-(g[y][x]=='^');
      int nx=x+(g[y][x]=='>')-(g[y][x]=='<');
      g[y][x]='\0';
      y=ny;
      x=nx;
    }
    if(g[y][x]){
      cout<<x<<' '<<y<<endl;
    }else{
      cout<<"LOOP"<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>

int main(){
  int a,b;
  while(std::cin>>a>>b){
    if(!a&&!b)return 0;
    char c[101][101];
    for(int y=0;y<a;y++){
      std::string s;
      std::cin>>s;
      for(int x=0;x<b;x++)
        c[y][x] = s[x];
    }
    int r[101][101]={0},t_x=0,t_y=0;
    while(c[t_y][t_x] != '.'){
      switch(c[t_y][t_x]){
      case '>':
        t_x++;
        break;
      case '<':
        t_x--;
        break;
      case 'v':
        t_y++;
        break;
      case '^':
        t_y--;
        break;
      }
      if(r[t_y][t_x]>1)break;
      r[t_y][t_x]++;
    }
    if(r[t_y][t_x]>1)std::cout<<"LOOP"<<std::endl;
    else{std::cout<<t_x<<" "<<t_y;}
  }
}