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<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
using namespace std;

int main(){
   int W,H,i,j;
   int map[200*200],flag[200*200];
   int answ,ansh,now;
   
   for(;;){
      cin>>W>>H;
      if(W==0&&H==0) break;
      memset(flag,0,sizeof(flag));
      answ=0;ansh=0;now=0;
      
      for(i=0;i<W;i++){
         for(j=0;j<H;j++){
            map[i*H+j] = getchar();
            if(map[i*H+j]=='\n')
               map[i*H+j] = getchar();
         }
      }
      
      while(flag[now]==0){
         flag[now]++;
         
         if(map[now]=='>'){
            answ++;
            now++;
         }
         else if(map[now]=='<'){
            answ--;
            now--;
         }
         else if(map[now]=='^'){
            ansh--;
            now-=H;
         }
         else if(map[now]=='v'){
            ansh++;
            now+=H;
         }
         else if(map[now]=='.'){
            flag[now]=0;
            break;
         }
      }
      if(flag[now] == 0)
         cout<<answ<<" "<<ansh<<endl;
      else
         cout<<"LOOP"<<endl;
   }
   return 0;
}

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

const int MAXH = 101;
const int MAXW = MAXH;

int H, W;
char g[MAXH][MAXW];

int main() {
  while(cin >> H >> W && (H|W)) {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> g[i][j];
      }
    }
    int x, y;
    x = y = 0;
    while(1) {
      char c = g[y][x];
      g[y][x] = '#';
      if(c == '>') ++x;
      if(c == '<') --x;
      if(c == '^') --y;
      if(c == 'v') ++y;
      if(c == '.') {
        cout << x << " " << y << endl;
        break;
      }
      if(c == '#') {
        cout << "LOOP" << endl;
        break;
      }
    }
  }
  return 0;
}

C++: /*****include*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return 0;
	}
#endif
	/*****変数置き場*****/
	char (**field);
	bool (**appear);
	char *buff;
	int height;
	int width;
	int x_ax,y_ax;
	/*****処理部*****/
	while(1){
		cin >> height >> width;
		if(height == 0 && width == 0)	break;
		field = new char* [height];
		appear = new bool* [height];
		buff = new char [height];
		for(int i=0;i<height;i++){
			field[i] = new char [width];
			appear[i] = new bool [width];
		}
		for(int i=0;i<height;i++){
			cin >> buff;
			for(int j=0;j<width;j++)
				field[i][j] = buff[j];
		}
		for(int i=0;i<height;i++)
			for(int j=0;j<height;j++)
				appear[i][j] = false;
		x_ax = 0;y_ax = 0;
		while(1){
			if(field[y_ax][x_ax] == '>'){
				x_ax++;
				if(appear[y_ax][x_ax]){
					cout << "LOOP" << endl;
					break;
				}
				appear[y_ax][x_ax] = true;
			}else if(field[y_ax][x_ax] == '<'){
				x_ax--;
				if(appear[y_ax][x_ax]){
					cout << "LOOP" << endl;
					break;
				}
				appear[y_ax][x_ax] = true;
			}else if(field[y_ax][x_ax] == 'v'){
				y_ax++;
				if(appear[y_ax][x_ax]){
					cout << "LOOP" << endl;
					break;
				}
				appear[y_ax][x_ax] = true;
			}else if(field[y_ax][x_ax] == '^'){
				y_ax--;
				if(appear[y_ax][x_ax]){
					cout << "LOOP" << endl;
					break;
				}
				appear[y_ax][x_ax] = true;
			}else if(field[y_ax][x_ax] == '.'){
				cout << x_ax << " " << y_ax << endl;
				break;
			}else{
				cout << "ERROR" << endl;
				break;
			}
		}
	}
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

string mt[200];
int used[200][200];

int main() {
	int h,w;
	while(~scanf("%d %d\n",&h,&w),h){
		int x,y;
		for(y=0;y<h;y++){
			cin>>mt[y];
		}
		memset(used,0,sizeof(used));
		pint pos(0,0);
//cout<<"hoge"<<endl;
//cout<<mt[0][0]<<endl;
//cout<<'>'<<endl;
		while(mt[pos.second][pos.first]!='.'){
//cout<<pos.first<<" "<<pos.second<<endl;
			if(used[pos.second][pos.first]==1)break;
			used[pos.second][pos.first]=1;
			if(mt[pos.second][pos.first]=='>'){
				pos.first++;
			}else if(mt[pos.second][pos.first]=='<'){
				pos.first--;
			}else if(mt[pos.second][pos.first]=='v'){
				pos.second++;
			}else{
				pos.second--;
			}
		}
		if(mt[pos.second][pos.first]!='.')cout<<"LOOP"<<endl;
		else cout<<pos.first<<" "<<pos.second<<endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int W, H;
	char field[100][100];
	bool passed[100][100];
	while(1)
	{
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		for(int y = 0;y < H;y++)
		{
			for(int x = 0;x < W;x++)
			{
				cin >> field[y][x];
				passed[y][x] = false;
			}
		}
		
		int cx = 0, cy = 0;
		bool loop = false;
		while(1)
		{
			int dx = 0, dy = 0;
			char cell = field[cy][cx];
			if(passed[cy][cx])
			{
				loop = true;
				break;
			}
			else if(cell == '>') dx++;
			else if(cell == '<') dx--;
			else if(cell == '^') dy--;
			else if(cell == 'v') dy++;
			else if(cell == '.') break;
			passed[cy][cx] = true;
			cx += dx;
			cy += dy;
		}
		if(loop) cout << "LOOP" << endl;
		else cout << cx << ' ' << cy << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
int main() {
	int h, w;
	while (cin >> h >> w, h, w) {
		char map[114][514];
		bool b[114][514] = {};
		rep(i, h)rep(j, w)cin >> map[i][j];
		int x = 1, y = 1;
		rep(i, 10010) {
			if (b[x][y]) { cout << "LOOP\n"; goto end; }
			b[x][y] = true;
			if (map[x][y] == '>')y++;
			else if (map[x][y] == '<')y--;
			else if (map[x][y] == '^')x--;
			else if (map[x][y] == 'v')x++;
			else {
				cout << --y << ' ' << --x << endl;
				goto end;
			}
		}
	end:;
	}
}