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 <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

int n, m;
string fi[110];

int main() {
    while (cin >> n >> m) {
        if (n == 0) break;
        for (int i = 0; i < n; ++i) cin >> fi[i];
        bool loop = false;
        bool seen[110][110] = {0};
        int x = 0, y = 0;
        while (fi[x][y] != '.') {
            if (fi[x][y] == '>') ++y;
            if (fi[x][y] == 'v') ++x;
            if (fi[x][y] == '<') --y;
            if (fi[x][y] == '^') --x;
            if (seen[x][y]) { loop = true; break; }
            seen[x][y] = true;
        }
        if (!loop) cout << y << " " << x << endl;
        else puts("LOOP");
    }
    return 0;
}

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

char tile[100][100];
bool memo[100][100];

template <typename T>
void init(T a[100][100]) {
  for(int i = 0; i < 100; ++i) {
	for(int j = 0; j < 100; ++j) {
	  a[i][j] = 0;
	}
  }
}

void Step(char tile[100][100]) {
  int h = 0, w = 0;

  while(1) {
	if(memo[h][w] == 1) {
	  cout << "LOOP" << endl;
	  break;
	}
	
	// '>'??????????????\???????????????
	if(tile[h][w] == '>') {
	  memo[h][w] = 1;
	  w++;
	}
	// '<'??????????????\???????????????
	else if(tile[h][w] == '<') {
	  memo[h][w] = 1;
	  w--;
	}
	
	// '^'??????????????\???????????????
	else if(tile[h][w] == '^') {
	  memo[h][w] = 1;
	  h--;
	}

	// 'v'??????????????\???????????????
	else if(tile[h][w] == 'v') {
	  memo[h][w] = 1;
	  h++;
	}

	// '.'??????????????\???????????????
	else {
	  cout << w << " " << h << endl;
	  break;
	}
  }// END:while

}

int main() {
  int H, W;
  while(cin >> H >> W) {
	if(H == 0 && W == 0) break;

	init<bool>(memo);
	init<char>(tile);
	
	for(int i = 0; i < H; ++i) {
	  for(int j = 0; j < W; ++j) {
		cin >> tile[i][j];
	  }
	}
	
	Step(tile);
  }

  return 0;
}

C++: #include<stdio.h>
int a,b,limx,limy;
char s[102][102];
int pass[102][102];
void check(int x,int y){
    if(pass[x][y]!=1){
        a=x,b=y;
        pass[x][y]=1;
        if(s[x][y]=='^'&&x-1>=0)
        check(x-1,y);
        if(s[x][y]=='v'&&x+1<limx)
        check(x+1,y);
        if(s[x][y]=='>'&&y+1<limy)
        check(x,y+1);
        if(s[x][y]=='<'&&y-1>=0)
        check(x,y-1);
    }
    else
    a=-1;
}
main(){
    int x,y,i,j;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)
        break;
        limx=x;limy=y;
        for(i=0;i<x;i++)
        for(j=0;j<y;j++)
        pass[x][y]=0;
        for(i=0;i<x;i++)
        scanf("%s",&s[i]);
        check(0,0);
        if(a!=-1)
        printf("%d %d\n",b,a);
        else
        printf("LOOP\n");
    }
}

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

int main() {
    int H, W;
    
    while (cin >> H >> W && H + W != 0) {
        char room[101][101];
        bool visited[101][101] = {0};

        for (int h = 0; h < H; ++h) {
            for (int w = 0; w < W; ++w) {
                cin >> room[h][w];
            }
        }

        int x = 0, y = 0;
        bool loop = false;

        while(room[x][y] != '.') {
            if (visited[x][y]) {
                loop = true;
                break;
            }
            else {
                visited[x][y] = true;
            }

            if (room[x][y] == '>') y++;
            else if (room[x][y] == '<') y--;
            else if (room[x][y] == '^') x--;
            else if (room[x][y] == 'v') x++;
        }

        if (loop) {
            cout << "LOOP" << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }

    return 0;
}

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

using namespace std;

int main(){
  for(int W,H;cin>>W>>H,W|H;){
    char g[200][200];
    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>
#include<vector>
#include<string>

using namespace std;

int judge[128][128];

int main()
{
	char f[128][128];

	int w, h, i, j, ex, ey;

	while(cin >> h >> w, w || h)
	{
		i = 0; j = 0;

		for(int k = 0; k < h; k++)
		{
			cin >> f[k];
			for(int l = 0; l < w; l++)
			{
				judge[k][l] = 0;
			}
		}
		while(1)
		{
			if(judge[i][j] == 1)
			{
				ex = -1; ey = -1;
				break;
			}
			else if(f[i][j] == '.')
			{
				ex = j; ey = i;
				break;
			}

			judge[i][j] = 1;

			if(f[i][j] == '>')
			{
				++j;
			}
			else if(f[i][j] == '<')
			{
				--j;
			}
			else if(f[i][j] == '^')
			{
				--i;
			}
			else if(f[i][j] == 'v')
			{
				++i;
			}
		}

		if(ex == -1 && ey == -1)
		{
			cout << "LOOP" << endl;
		}
		else
		{
			cout << ex << ' ' << ey << endl;
		}
	}
}

C++: #include<iostream>
using namespace std;
int w,h,v[200][200];
char s[200][200];
void func(int y,int x){
	v[y][x]=0;
	if(s[y][x]=='.')
		cout<<x<<' '<<y<<endl;
	else if(s[y][x]=='>'){
		if(v[y][x+1]==1)
			func(y,x+1);
		else
		cout<<"LOOP"<<endl;
	}
	else if(s[y][x]=='<'){
		if(v[y][x-1]==1)
			func(y,x-1);
		else
		cout<<"LOOP"<<endl;
	}
	else if(s[y][x]=='v'){
		if(v[y+1][x]==1)
			func(y+1,x);
		else
		cout<<"LOOP"<<endl;
	}
	else if(s[y][x]=='^'){
		if(v[y-1][x]==1)
			func(y-1,x);
		else
		cout<<"LOOP"<<endl;
	}
	
}

int main(){
	while(cin>>h>>w,w||h){
		for(int i=0;i<h;i++)
		cin>>s[i];
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		v[i][j]=1;
		func(0,0);
	}
	return 0;
}