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 <string>

using namespace std;


int w,h;

int map[10001];
bool visited[10001];

int move(int pos) {

  if(visited[pos]==true) return -1;

  else {

    visited[pos]=true;

    switch(map[pos]) {

    case 0:
      return pos;

    case 1:
      return move(pos+1);

    case 2:
      return move(pos-w);

    case 3:
      return move(pos-1);

    case 4:
      return move(pos+w);

    }

  }

  return -1;

}

int main() {

  string buf;

  int res;
  

  while(cin >> h >> w) {

    if(w==0 && h==0) break;

    getline(cin,buf);

    for(int i=0;i<10001;i++) visited[i]=false;

    for(int i=0;i<h;i++) {

      getline(cin,buf);

      for(int j=0;j<w;j++) {

	switch(buf[j]) {

	case '.':
	  map[i*w+j]=0;
	  break;

	case '>':
	  map[i*w+j]=1;
	  break;

	case '^':
	  map[i*w+j]=2;
	  break;

	case '<':
	  map[i*w+j]=3;
	  break;

	case 'v':
	  map[i*w+j]=4;
	  break;

	}

      }

    }
    /*
    for(int i=0;i<h;i++) {

      for(int j=0;j<w;j++) {

	cout << map[i*w+j];

      }

      cout << endl;

    }
    */
    res=move(0);

    if(res==-1) cout << "LOOP" << endl;

    else cout << res%w << " " << res/w << endl;
    
  }

  return 0;

}

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

int x;
int y;
int h;
int w;
bool loop;
char symbols[] = "<^>v";
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
char field[1000][1000];
bool used[1000][1000];

int main() {
  while (1) {
    scanf("%d%d", &h, &w);
    if (w == 0 && h == 0) return 0;
    
    for (int i=0; i<h; i++) {
      for (int j=0; j<w; j++) {
        scanf(" %c", &field[i][j]);
        used[i][j] = false;
      }
    }

    x = 0;
    y = 0;
    loop = false;
    while (1) {
      if (field[y][x] == '.') break;
      if (used[y][x]) {
        loop = true;
        break;
      }
      used[y][x] = true;

      for (int i=0; i<4; i++) {
        if (field[y][x] == symbols[i]) {
          y += dy[i];
          x += dx[i];
          break;
        }
      }
    }

    if (!loop) printf("%d %d\n", x, y);
    else puts("LOOP");
  }
}

C++: #include <iostream>
using namespace std;
int main(){
	char data[101][101];
	bool f[101][101];
	int h,w;
	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>>data[j][i];
				f[j][i]=true;
			}
		}
		int x=0,y=0;
		while(1){
			if(!f[x][y]){
				cout<<"LOOP"<<endl;
				break;
			}
			f[x][y]=false;
			if(data[x][y]=='>')x++;
			else if(data[x][y]=='<')x--;
			else if(data[x][y]=='^')y--;
			else if(data[x][y]=='v')y++;
			else{
				cout<<x<<" "<<y<<endl;
				break;
			}
		}
	}
}

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <set>
using namespace std;
bool calc(vector<vector<char> >, int y, int x);
int resultx;
int resulty;
set<string> passed;

int main() {
  while(true) {
    passed.clear();
  int width, height;
  cin >> width >> height;
  if(width == 0 && height == 0) break;
  vector<vector<char> > field(width, vector<char>(height));
  for(int w = 0; w < width; ++w) {
    for(int h = 0; h < height; ++h) {
      cin >> field[w][h];
    }
  }
  if(calc(field, 0, 0)) cout << resulty << " " << resultx << endl;
  }
  return 0;
}

bool calc(vector<vector<char> > field, int y, int x) {
  stringstream ss;
  ss << y << ',' << x;
  // cout << ss.str() << endl;
  if(passed.find(ss.str()) != passed.end()) {
    cout << "LOOP" << endl;
    return false;
  }
  passed.insert(ss.str());
  switch(field[x][y]) {
    case '>':
      return calc(field, y + 1, x);
      break;
    case '<':
      return calc(field, y - 1, x);
      break;
    case '^':
      return calc(field, y, x - 1);
      break;
    case 'v':
      return calc(field, y, x + 1);
      break;
    case '.':
      resultx = x;
      resulty = y;
      return true;
  }
}

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

int main() {
	
	int w,h;
	int *tile;
	int tmp;
	int x,y;
	
	while(cin>>h>>w,w||h){
		tile = new int[w*h];
		x=y=0;
		
		for(int i=0;i<w*h;++i){
			tmp = getchar();
			if(tmp == '\n'){--i;continue;}
			tile[i] = tmp;
		}
		
		while(1){
			
			if(tile[x+y*w] == 0){
				cout<<"LOOP"<<endl;
				break;
			}
			
			if(tile[x+y*w] == '.'){
				cout<<x<<" "<<y<<endl;
				break;
			}
			
			tmp = tile[x+y*w];
			
			tile[x+y*w] = 0;
			
			
			switch(tmp){
				
				case '>':
				++x;
				break;
				
				case '<':
				--x;
				break;
				
				case '^':
				--y;
				break;
				
				case 'v':
				++y;
				break;
			}
		}
	}

	delete[]tile;
	
	return 0;
}

C++: #include <stdio.h>
typedef enum Tile{
	North,East,West,South,No,Passed
}Tile;

int src[5][2]={{-1,0},{0,1},{0,-1},{1,0},{0,0}};

class Pair{
public:
	Pair(){x=y=0;}
	void move(Tile t);
	int x,y;
};
void Pair::move(Tile t){
	x+=src[t][0];
	y+=src[t][1];
}


int main(){
	while(1){
		int h,w;
		bool stop=false;
		Pair pos;
		char c[101][101];
		scanf("%d%d",&h,&w);
		if(!h&&!w) break;
		for(int i=0;i<h;i++) scanf("%s",c[i]);
		while(!stop){
			Pair tmp=pos;
			switch(c[pos.x][pos.y]){
			case '^':
				pos.move(Tile::North);
				break;
			case '>':
				pos.move(Tile::East);
				break;
			case '<':
				pos.move(Tile::West);
				break;
			case 'v':
				pos.move(Tile::South);
				break;
			case '.':
				stop=true;
				printf("%d %d\n",pos.x,pos.y);
				break;
			case 0:
				stop=true;
				printf("LOOP\n");
			}
			c[tmp.x][tmp.y]=0;
		}
	}
	return 0;
}

C++: #include <string>
#include <iostream>
using namespace std;
int H, W; string S[100]; bool used[100][100];
void solve(int x, int y) {
	if (used[y][x]) { printf("LOOP\n"); return; } used[y][x] = true;
	switch (S[y][x]) {
		case '.': printf("%d %d\n", x, y); break;
		case '>': solve(x + 1, y); break;
		case '<': solve(x - 1, y); break;
		case 'v': solve(x, y + 1); break;
		case '^': solve(x, y - 1); break;
	}
}
int main() {
	while (true) {
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) cin >> S[i];
		for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) used[i][j] = false;
		solve(0, 0);
	}
	return 0;
}

C++: #include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int w,h;
	char s[1001][1001];
	for(;;){
		scanf("%d%d",&h,&w);
		if(h==0&&w==0)break;
		rep(i,h)scanf("%s",s[i]);
		int x,y;
		x=y=0;
		while(s[y][x]!='.' && s[y][x]!='l'){
			char c=s[y][x];
			s[y][x]='l';
			if(c=='v')y++;
			else if(c=='^')y--;
			else if(c=='>')x++;
			else if(c=='<')x--;
		}
		if(s[y][x]=='.')printf("%d %d\n",x,y);
		else puts("LOOP");
	}
	return 0;
}