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;

void  move(char t[100][100][2], int *x, int *y) {
  t[*y][*x][1] = 1;
  if (t[*y][*x][0] == '>')
    (*x)++;
  else if (t[*y][*x][0] == '<')
    (*x)--;
  else if (t[*y][*x][0] == '^')
    (*y)--;
  else if (t[*y][*x][0] == 'v')
    (*y)++;
}

int main(int argc, char *argv[]) {
  int h, w;
  char tile[100][100][2];
  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0)
      break;

    string tmp;
    // skip '\n'                                                                                                                                                                                            
    getline(cin, tmp);
    for (int i = 0; i < h; i++) {
      getline(cin, tmp);
      for (int j = 0; j < w; j++) {
        tile[i][j][0] = tmp[j];
        tile[i][j][1] = 0;
      }
    }
    /*                                                                                                                                                                                                      
    for (int i = 0; i < h; i++) {                                                                                                                                                                           
      for (int j = 0; j < w; j++)                                                                                                                                                                           
        cout << tile[i][j][0];                                                                                                                                                                              
      cout << endl;                                                                                                                                                                                         
    }                                                                                                                                                                                                       
    */
    int x = 0, y = 0;
    while (true) {
      move(tile, &x, &y);
      /*                                                                                                                                                                                                    
      cout << x << ' ' << y << endl;                                                                                                                                                                        
      */
      if (tile[y][x][0] == '.') {
        cout << x << ' ' << y << endl;
        break;
      } else if (tile[y][x][1] > 0) {
        cout << "LOOP" << endl;
        break;
      }
    }
  }
  return 0;
}

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

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

    char mp[102][102];
    int flag[102][102]={0};
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)scanf(" %c",&mp[i][j]);
    }

    int nh=0,nw=0;
    while(mp[nh][nw]!='.' && flag[nh][nw]==0){
      flag[nh][nw]=1;
      if(mp[nh][nw]=='>')nw++;
      if(mp[nh][nw]=='<')nw--;
      if(mp[nh][nw]=='^')nh--;
      if(mp[nh][nw]=='v')nh++;
      
    }

    if(flag[nh][nw])printf("LOOP\n");
    else printf("%d %d\n",nw,nh);

  }
  return(0);
}

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

int main() {
    int X, Y;
    
    while (cin >> X >> Y && X + Y != 0) {
        char room[20][20];
        for (int x = 0; x < X; ++x) {
            for (int y = 0; y < Y; ++y) {
                cin >> room[x][y];
            }
        }

        int steps = 0;
        int x = 0, y = 0;
        while (room[x][y] != '.' && steps < 10000) {
            if (room[x][y] == '>') {
                y++;
            }
            if (room[x][y] == '<') {
                y--;
            }
            if (room[x][y] == '^') {
                x--;
            }
            if (room[x][y] == 'v') {
                x++;
            }
            steps++;
        }
        if (steps >= 10000) {
            cout << "LOOP" << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

void solve105(int H, int W) {
    vector<vector<int>> visited(H, vector<int>(W,0));
    vector<vector<char>> floor(H, vector<char>(W,0));
    string s;
    REP(i,H) {
        cin >> s;
        REP(j,W) {
            floor[i][j] = s[j];
        }
    }
    int x = 0; int y = 0;
    while (floor[y][x] != '.') {
        if (visited[y][x]) {
            cout << "LOOP" << endl;
            return;
        }
        visited[y][x] = 1;
        if (floor[y][x] == '>') {
            x++;
        }else if (floor[y][x] == '<') {
            x--;
        }else if (floor[y][x] == 'v') {
            y++;
        }else {
            y--;
        }
    }
    cout << x << " " << y << endl;
}

int main() {
    int H, W;
    while (cin >> H >> W, H + W) {
        solve105(H, W);
    }
}

C++: #include<cstdio>
using namespace std;
int main(){
  int h,w;
  char c[101][101];
  scanf("%d %d",&h,&w);
  while(h != 0 && w != 0){
    for(int i=0;i<h;i++){
      scanf("%s",c[i]);
    }
    int x=0,y=0;
    while(c[y][x] != '.'){
      
      if(c[y][x] == '0'){
	printf("LOOP\n");
	break;
      }else if(c[y][x] == '>'){
	c[y][x] = '0';
	x++;
      }else if(c[y][x] == '<'){
	c[y][x] = '0';
	x--;
      }else if(c[y][x] == '^'){
	c[y][x] = '0';
	y--;
      }else if(c[y][x] == 'v'){
	c[y][x] = '0';
	y++;
      }
    }
    if(c[y][x] != '0') printf("%d %d\n",x,y);
    scanf("%d %d",&h,&w);
  }
  return (0);
}

C++: #include <iostream>
#include <vector>

using namespace std;

int main(){
    int w,h;
    int i,j;
    while(1){
        cin >> w;
        cin >> h;
        if(w == 0 || h == 0) break;
        vector< vector<char> > v(h, vector<char>(w));
        for(j=0;j<h;++j){
            for(i=0;i<w;++i){
                cin >> v[i][j];
            }
        }
        int mi = 0, mj = 0;
        while(true){
            char c = v[mi][mj];
            v[mi][mj] = '#';
            if(c == '>') mi++;
            else if(c == '<') mi--;
            else if(c == '^') mj--;
            else if(c == 'v') mj++;
            else if(c == '#'){
                cout << "LOOP" << endl;
                break;
            } else if( c == '.' ){
                cout << mi << ' ' << mj << endl;
                break;
            }
        }
    }
    return 0;
}