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 <stdio.h>

char map[100][100];
int done[100][100];

int main(){
  while(1){
    int w,h;
    scanf("%d%d", &w, &h);

    if(w==0) break;

    int i,j;
    for(i=0;i<h;i++) for(j=0;j<w;j++){
       done[i][j] = 0;
       scanf(" %c", &map[i][j]);
      }

    int x,y;
    x = y = 0;
    
    while(!done[x][y]){
      if(map[x][y] == '.') break;
      done[x][y] = 1;
      if(map[x][y] == '>') y++;
      else if(map[x][y] == 'v') x++;
      else if(map[x][y] == '^') x--;
      else if(map[x][y] == '<') y--;
    }

    if(done[x][y]) puts("LOOP");
    else printf("%d %d\n", y, x);
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int MAX_H = 100;
const int MAX_W = 100;
char m[MAX_H+1][MAX_W+1];
int h, w;
bool used[MAX_H+1][MAX_W+1];

int main()
{
  while((cin >> h >> w) && h && w){
    rep(i, h) rep(j, w) used[i][j] = false;
    rep(i, h) rep(j, w) cin >> m[i][j];

    int hx = 0;
    int hy = 0;
    while(true){
    used[hx][hy] = true;
    if(m[hx][hy] == '>') hy += 1;
    if(m[hx][hy] == '<') hy -= 1;
    if(m[hx][hy] == '^') hx -= 1;
    if(m[hx][hy] == 'v') hx += 1;
    if(m[hx][hy] == '.'){ cout << hy << " " << hx << endl; break;}
    if(used[hx][hy]){ cout << "LOOP" << endl;  break; }
    }
  }

  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, tmp2 = 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, tmp2 = 0, tmpc = 1;
    x = 0, y = 0;
    while (tmpc) {
      if (tmp2 == 20000) break;
      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;
      tmp2++;
      // debugp("Debug: %c %d %d\n", map[x][y], (x+1), (y+1));
    }
    if (tmp2 == 2000) puts("LOOP");
    else printf("%d %d\n", (x+1), (y+1));
    scanf("%d %d", &mapx, &mapy);
  }
  return 0;
}

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

int main(){
    int h,w;
    while(1){
        int h,w;
        scanf("%d %d",&h,&w);
        cin.ignore();
        if (h==0 & w==0){
            return 0;
        }
        char ma[100][100];
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                scanf(" %c",&ma[i][j]);
            }
        }
        int px,py;
        px = py = 0;
        while(1){
            // printf("%d %d %c\n",py,px,ma[py][px]);
            switch(ma[py][px]){
                case '>':
                    ma[py][px] = 'x';
                    px += 1;
                    break;
                case '^':
                    ma[py][px] = 'x';
                    py -= 1;
                    break;
                case '<':
                    ma[py][px] = 'x';
                    px -= 1;
                    break;
                case 'v':
                    ma[py][px] = 'x';
                    py += 1;
                    break;
            }
            if(ma[py][px] == 'x'){
                printf("LOOP\n");
                break;
            }else if (ma[py][px] == '.'){
                printf("%d %d\n", px,py);
                break;
            }
        }
    }
    return 0;
}

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

int main(){
	int w,h;
	string m[110];
	bool f[110][110], flag;
	
	while( cin >> h >> w , w, h ){
		flag = false;
		for(int y=0 ; y<h ; y++){
			m[y].clear();
			for(int x=0 ; x<w ; x++){
				f[y][x] = false;
			}
		}
		for(int y=0 ; y<h ; y++){
			cin >> m[y];
		}
		int x=0, y=0;
		while(1){
			if( m[y][x]=='>' ) x++;
			if( m[y][x]=='<' ) x--;
			if( m[y][x]=='v' ) y++;
			if( m[y][x]=='^' ) y--;
			
			if( m[y][x]=='.' || f[y][x] ){
				if( f[y][x] ) flag = true ;
				break;
			}
			f[y][x] = true;
		}
		(flag)? (cout << "LOOP" << endl) : (cout << x << " " << y << endl); 
	}
	return 0;
}

C++: #include<iostream>
#include<string>
char pos[100][100] = {};
int X, Y, mem[100][100] = {}, n, m;
int f(int x, int y) {
	if (mem[x][y] == 1) {
		return 1;
	}
	mem[x][y] = 1;
	if (pos[x][y] == '<') {
		if (y == 0)
			return 1;
		y -= 1;
	}
	else if (pos[x][y] == '>') {
		if (y == m - 1)
			return 1;
		y += 1;
	}
	else if (pos[x][y] == '^') {
		if (x == 0)
			return 1;
		x -= 1;
	}
	else if (pos[x][y] == 'v') {
		if (x == n - 1)
			return 1;
		x += 1;
	}
	else if (pos[x][y] == '.') {
		X = x;
		Y = y;
		return 0;
	}
	return f(x, y);
}
int main() {
	while (std::cin >> n >> m, n + m != 0) {
		X = 0, Y = 0;
		for (int i = 0; i < n; i += 1)
			for (int j = 0; j < m; j += 1) {
				std::cin >> pos[i][j];
				mem[i][j] = 0;
			}
		int ans = f(0, 0);
		if (ans == 1)
			std::cout << "LOOP" << std::endl;
		else std::cout << Y <<" "<< X << std::endl;
	}
	return 0;
}

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

int main(void) {
  int H, W;
  cin >> H >> W;
  vector<vector<char> > tiles(H, vector<char>(W));

  for (auto i = 0; i < H; i++) {
    for (auto j = 0; j < W; j++) {
      cin >> tiles[i][j];
    }
  }

  bool flag = true;
  int nowX = 0, nowY = 0;
  int max_num = H * W + 1;
  while (max_num-- && flag) {
    switch(tiles[nowY][nowX]) {
    case '>':
      nowX++;
      break;
    case '<':
      nowX--;
      break;
    case '^':
      nowY--;
      break;
    case 'v':
      nowY++;
      break;
    default:
      flag = false;
      break;
    }
  }

  if (max_num > 0) {
    cout << nowX << " " << nowY << endl;
  } else {
    cout << "LOOP" << endl;
  }

  return 0;
}