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>

int main(int argc, char **argv)
{
	int h, w;
	int x = 0, y = 0;
	char tiles[100][100];
	bool throughed[100][100] = {};
	bool loop = false;
	bool end = false;
	while(std::cin >> h >> w, h+w != 0){
		x = 0;
		y = 0;
		for(int i = 0; i < 100; i++){
			for(int j = 0; j < 100; j++){
				throughed[j][i] = false;
			}
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				std::cin >> tiles[j][i];
			}
		}
		while(true){
			if(throughed[x][y]){
				loop = true;
				break;
			}
			throughed[x][y] = true;
			switch(tiles[x][y]){
				case '.':
					end = true;
					break;
				case '^':
					y--;
					break;
				case 'v':
					y++;
					break;
				case '<':
					x--;
					break;
				case '>':
					x++;
					break;
			}
			if(end){
				break;
			}
		}
		if(loop){
			std::cout << "LOOP" << std::endl;
		}else{
			std::cout << x << " " << y << std::endl;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define debug(A) puts(A)
#define debugp(A,B) printf(A,B)
#define debugs(A,B) scanf(A,B)
using namespace std;

int main() {
  int mapx, mapy;
  int x, y, tmp0 = 0, tmp1 = 0;
  char map[150][150] = {0}, tmpc = 1;
  scanf("%d %d", &mapx, &mapy);
  while (mapx+mapy) {
    scanf("%c", &tmpc);
    while (tmp0 < mapx) {
      tmp1 = 0;
      while (tmp1 < mapy) {
        scanf("%c", &map[tmp0][tmp1]);
        tmp1++;
      }
      scanf("%c", &tmpc);
      tmp0++;
    }
    tmp0 = 0, tmp1 = 0, tmpc = 1;
    x = 0, y = 0;
    while (tmpc) {
      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 if (map[x][y] == '.') tmpc = 0;
      else tmpc = 0;
      // debugp("Debug: %c %d %d\n", map[x][y], (x+1), (y+1));
    }
    printf("%d %d\n", (x+1), (y+1));
    scanf("%d %d", &mapx, &mapy);
  }
  return 0;
}

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