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>

void move(int, int);

char tiles[100][100];
bool mem[100][100];

int main()
{
  int H, W;
  while(true)
  {
    std::cin >> H >> W;
    if(!H && !W)
      break;
    for(int i = 0; i < 10000; i++)
      mem[i / 100][i % 100]  = 0;

    for(int i = 0; i < H; i++)
      std::cin >> tiles[i];

    move(0, 0);
  }
  return 0;
}

void move(int x, int y)
{
  if(mem[y][x])
  {
    std::cout << "LOOP" << std::endl;
    return;
  }

  mem[y][x] = true;

  switch(tiles[y][x])
  {
    case '<':
      move(x - 1, y);
      return;
    case '>':
      move(x + 1, y);
      return;
    case '^':
      move(x, y - 1);
      return;
    case 'v':
      move(x, y + 1);
      return;
    case '.':
      std::cout << x << " " << y << std::endl;
      return;
  }
}

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

#define loop for (;;)
#define repeat(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
  loop {
    int H, W;
    cin >> H >> W;
    if (!H && !W) return 0;
    string room[H];
    bool visited[H][W];
    memset(visited, 0, sizeof visited);
    int x = 0, y = 0;
    repeat(i, H)
      cin >> room[i];
    for (bool finish = false; !finish;) {
      if (visited[y][x]) {
        cout << "LOOP" << endl;
        finish = true;
      } else
        visited[y][x] = true;
      switch (room[y][x]) {
      case '>': x++; break;
      case '<': x--; break;
      case '^': y--; break;
      case 'v': y++; break;
      case '.':
        cout << x << ' ' << y << endl;
        finish = true;
        break;
      default: break;
      }
    }
  }
}

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

int main(){
    int w,h;
    int ichi[101][101]={0};
    while(1){
        int i=0,j=0;
        cin >> w >> h;
        if(w == 0 && h == 0){
            break;
        }
        char map[w][h];
        for(int n=0;n<w;n++){
            for(int k=0;k<h;k++){
                cin >> map[n][k];
            }
        }
        while(1){
            for(int n=0;n<w;n++){
                memset(ichi[n],0,sizeof(ichi[i]));
            }
            if(ichi[i][j] == 1){
                cout << "LOOP" << endl;
                break;
            }
            else if(map[i][j] == '.'){
                cout << j << " " << i << endl;
                break;
            }
            if(map[i][j] == '>'){
                ichi[i][j] = 1;
                j++;
            }
            else if(map[i][j] == '<'){
                ichi[i][j] = 1;
                j--;
            }
            else if(map[i][j] == '^'){
                ichi[i][j] = 1;
                i--;
            }
            else if(map[i][j] == 'v'){
                ichi[i][j] = 1;
                i++;
            }
        }
    }

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<vector>
#include<cstdio>
#include<climits>
#include<cfloat>
#include<cstring>
#define foreach(t,p) for(t::iterator it=p.begin();it!=p.end();++it)
#define rforeach(t,p) for(t::reverse_iterator it=p.rbegin();it!=p.rend();++it)
#define all(p) p.begin(),p.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define FOREACH(t,p,tit) for(t::iterator tit=p.begin();tit!=p.end();++tit)
using namespace std;
char tiles[110][110];

int main()
{
    int w,h;
    while(cin >> h >> w)
    {
        memset(tiles,'.',sizeof(tiles));
        if(w==0&&h==0){break;}
        rep(j,h)rep(i,w){cin >> tiles[i][j];}

        int x,y,nextx,nexty;
        x=0;
        y=0;
        int loop = 0;
        char nowtile;
        while(1)
        {
            nowtile = tiles[x][y];
            tiles[x][y] = 'x';
            if(nowtile=='x'){loop=1;break;}
            if(nowtile=='.'){break;}
            if(nowtile=='>'){x++;continue;}
            if(nowtile=='<'){x--;continue;}
            if(nowtile=='v'){y++;continue;}
            if(nowtile=='^'){y--;continue;}

        }
        if(loop){cout << "LOOP"<<endl;continue;}
        //cout <<x << " "<<y << endl;
        printf("%d %d\n",x,y);
    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,m;
  while(cin >>n>>m,n||m){
    cin.ignore();
    int field[101][101] = {0},x = 0,y = 0;
    bool check[101][101] = {false};
    for(int i=0; i<n; i++){
      for(int j=0; j<m; j++){
	char c;
	scanf("%c",&c);
	if(c == '>'){field[j][i] = 1;}
	if(c == '<'){field[j][i] = 2;}
	if(c == '^'){field[j][i] = 3;}
	if(c == 'v'){field[j][i] = 4;}
      }
      scanf("%*c");
    }
    for(;;){
      if(check[x][y]){x = -1;cout <<"LOOP"<<endl;break;}
      check[x][y] = true;
      if(!field[x][y]){break;}
      else if(field[x][y] == 1){x++;}
      else if(field[x][y] == 2){x--;}
      else if(field[x][y] == 3){y--;}
      else if(field[x][y] == 4){y++;}
    }
    if(x>=0){cout <<x<<" "<<y<<endl;}
  }
  return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
char a[1000][1000]; int h, w, loop, cx, cy;
int main() {
	while (true) {
		cin >> h >> w;
		if (!h) { break; }
		memset(a, ' ', sizeof(a));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> a[i][j];
			}
		}
		cx = 0; cy = 0; loop = 0;
		while (true) {
			if (loop > 20000000) { cout << "LOOP" << endl; break; }
			if (a[cy][cx] == '.') { cout << cx << ' ' << cy << endl; break; }
			if (a[cy][cx] == '<') { cx--; }
			if (a[cy][cx] == '>') { cx++; }
			if (a[cy][cx] == '^') { cy--; }
			if (a[cy][cx] == 'v') { cy++; }
			loop++;
		}
	}
}

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

struct point{
	char c;
	int count;
};

void move(point area[100][100], int &i, int &j){
	area[i][j].count = 0;
	if(area[i][j].c == '>'){
		j++;
	}else if(area[i][j].c == '<'){
		j--;
	}else if(area[i][j].c == 'v'){
		i++;
	}else if(area[i][j].c == '^'){
		i--;
	}
}

int main(){
	int h, w;
	string s;
	point area[100][100];
	while(cin >> h >> w){
		if(h == 0 && w == 0) break;
		for(int i = 0; i < h; i++){
			cin >> s;
			for(int j = 0; j < s.size(); j++){
				area[i][j].c = s[j];
				area[i][j].count = 1;
			}
		}
		int i = 0, j = 0;
		while((area[i][j].c != '.') && (area[i][j].count == 1)){
			move(area, i, j);
		}
		if(area[i][j].c == '.') cout << j << " " << i << endl;
		else cout << "LOOP" << endl;
	}
	return 0;
}

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