Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	// var w, h int
	for scanner.Scan() {
		// fmt.Scanf("%d %d", &w, &h)

		input := strings.Split(scanner.Text(), " ")
		w, _ := strconv.Atoi(input[0])
		h, _ := strconv.Atoi(input[1])

		if w == 0 && h == 0 {
			return
		}

		isArrive := make([][]bool, w)
		tiles := make([][]string, w)

		for i := 0; i < w; i++ {
			rowArrive := make([]bool, h)
			rowTiles := make([]string, h)
			scanner.Scan()
			row := scanner.Text()
			for j := 0; j < h; j++ {
				rowTiles[j] = string(row[j])
			}
			tiles[i] = rowTiles
			isArrive[i] = rowArrive
		}

		var i, j int
		isEnd := false
		for {
			if isArrive[i][j] == true {
				fmt.Println("LOOP")
				break
			}
			isArrive[i][j] = true

			switch tiles[i][j] {
			case ">":
				j++
			case "^":
				i--
			case "v":
				i++
			case "<":
				j--
			case ".":
				isEnd = true
			}

			if isEnd == true {
				fmt.Println(j, i)
				break
			}
		}
	}
}

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

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
int main( void )
{
	while ( 1 )
	{
		int w, h;
		cin >> w >> h;
		if ( w == 0 && h == 0 )
			break;

		vector <string> data;
		for ( int i = 0; i < h; i++ )
		{
			string line;
			cin >> line;
			data.push_back( line );
		}

		bool loop_flag = false;
		int x = 0;
		int y = 0;
		while ( 1 )
		{
			int oldx = x;
			int oldy = y;
			if ( data[y][x] == '.' )
				break;
			else if ( data[y][x] == '>' )
				x++;
			else if ( data[y][x] == 'v' )
				y++;
			else if ( data[y][x] == '^' )
				y--;
			else if ( data[y][x] == '<' )
				x--;
			else if ( data[y][x] == 'x' )
			{
				loop_flag = true;
				break;
			}
			data[oldy][oldx] = 'x';
		}

		if ( loop_flag )
			cout << "LOOP" << endl;
		else
			cout << x << " " << y << endl;

	}
	return 0;
}