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 <vector>
using namespace std;

int main() {
    int H, W;
    
    while (cin >> H >> W && H + W != 0) {
        cin.get();
        cin.get();
        vector<string> room;
        for (int h = 0; h < H; ++h) {
            string line;
            getline(cin, line);
            room.push_back(line);
        }

        int steps = 0;
        int x = 0, y = 0;
        bool loop = false;

        while (room[x][y] != '.') {
            if (room[x][y] == '!') {
                loop = true;
                break;
            }
            if (room[x][y] == '>') {
                room[x][y] = '!';
                y++;
            }
            if (room[x][y] == '<') {
                room[x][y] = '!';
                y--;
            }
            if (room[x][y] == '^') {
                room[x][y] = '!';
                x--;
            }
            if (room[x][y] == 'v') {
                room[x][y] = '!';
                x++;
            }
        }

        if (loop) {
            cout << "LOOP" << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }
    return 0;
}

C++: #include <iostream>
#include <utility>
#define x pos.second
#define y pos.first
using namespace std;

int main(){
    int h, w;

    while(cin >> h >> w, h != 0 || w != 0){
        char map[h][w];
        pair<int, int> pos;
        bool loop = false;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cin >> map[j][i];
            }
        }
        pos.first = 0;
        pos.second = 0;
        while(1){
            if(map[x][y] == '!'){
                loop = true;
                break;
            }
            if(map[x][y] == '.'){
                break;
            }
            if(map[x][y] == '>'){
                map[x][y] = '!';
                x++;
            }
            else if(map[x][y] == '<'){
                map[x][y] = '!';
                x--;
            }
            else if(map[x][y] == 'v'){
                map[x][y] = '!';
                y++;
            }
            else if(map[x][y] == '^'){
                map[x][y] = '!';
                y--;
            }
        }
        if(loop) cout << "LOOP" << endl;
        else cout << x << " " << y << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
using namespace std;
int main() {
	int H,W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) {
			break;
		}
		string tile[100];
		bool memo[100][100];
		for (int i = 0;i < H;i++) {
			cin >> tile[i];
			for (int j = 0;j < W;j++) {
				memo[i][j] = false;
			}
		}
		int x = 0;
		int y = 0;
		while (true) {
			if (memo[x][y]) {
				cout << "LOOP" << endl;
				break;
			}
			if (tile[x][y] == '.') {
				cout << y << " " << x << endl;
				break;
			}
			memo[x][y] = true;
			if (tile[x][y] == '>') {
				y++;
			}
			if (tile[x][y] == '<') {
				y--;
			}
			if (tile[x][y] == '^') {
				x--;
			}
			if (tile[x][y] == 'v') {
				x++;
			}

		}
	}
	return 0;

}

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

int main() {
    int tate,yoko;
    char panel;
    
    while(1){
     cin>>tate>>yoko;
        if(tate==0&&yoko==0)break;
               int move[105][105]={};
        for(int i=0; i<tate; i++){
            for(int s=0;s<yoko; s++){
                cin>>panel;
                if(panel=='<')move[i][s]=1;
                if(panel=='>')move[i][s]=2;
                if(panel=='^')move[i][s]=3;
                if(panel=='v')move[i][s]=4;
            }
        }
        int movet,movey=0;
        
        while(1){
            if(move[movet][movey]==5){
                cout<<"LOOP"<<endl;
                break;
            }

            if(move[movet][movey]==1){
                move[movet][movey]=5;
                movey--;
            }
            if(move[movet][movey]==2){
                move[movet][movey]=5;
                movey++;
            }
            if(move[movet][movey]==3){
                move[movet][movey]=5;
                movet--;
            }
            if(move[movet][movey]==4){
                move[movet][movey]=5;
                movet++;
            }
            if(move[movet][movey]==0){
                cout<<movey<<" "<<movet<<endl;
                break;
            }
            cout<<movey<<" "<<movet<<endl;
                    }
        }
    return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	int h,w,x,y;
	char dp[150][150];
	while(true){
	cin>>h>>w;
	if(h==0&&w==0)
		break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>dp[i][j];
		}
	}
	x=0,y=0;
	int i=0;
	bool loop=false;
	while(true){
		if(dp[x][y]=='>')
			y+=1;
		if(dp[x][y]=='<')
			y-=1;
		if(dp[x][y]=='^')
			x-=1;
		if(dp[x][y]=='v')
			x+=1;
		if(dp[x][y]=='.')
			break;
		i++;
		if(i==h*w){
			cout<<"LOOP"<<endl;
			loop=true;
			break;
		}
	}
	if(loop==false)
	cout<<y<<" "<<x<<endl;
	}
	return 0;
}

C++: loop do
  n,m=gets.split.map(&:to_i)
  break if n==0
  px,py,cnt=0,0,0
  arr=Array.new()
  n.times do 
    arr<<gets.chomp.split("")
  end
  loop do
    case arr[py][px]
    when "<" then px-=1
    when ">" then px+=1
    when "^" then py-=1
    when "v" then py+=1
    else break
    end
    cnt+=1
    break if cnt>n*m
  end
  puts cnt>n*m ? "LOOP": "#{px} #{py}"
end

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <set>
using namespace std;
void calc(vector<vector<char> >, int y, int x);
int resultx;
int resulty;
set<string> passed;

int main() {
  while(true) {
  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 '>':
      calc(field, y + 1, x);
      break;
    case '<':
      calc(field, y - 1, x);
      break;
    case '^':
      calc(field, y, x - 1);
      break;
    case 'v':
      calc(field, y, x + 1);
      break;
    case '.':
      resultx = x;
      resulty = y;
      return true;
  }
}