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

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

int main(void){
	char array[100][100];
	int i,j,w,h;
	while(1){
		cin >> w;
		cin >> h;
		if(w == 0 || h == 0) break;
		for(i=0;i<w;i++) for(j=0;j<h;j++) cin >> array[i][j];		
		i=0;j=0;
		while(1){
			if(array[i][j] == '>'){ array[i][j] = '/'; j++;}
			else if(array[i][j] == '<'){ array[i][j] = '/'; j--;}
			else if(array[i][j] == '^'){ array[i][j] = '/'; i--;}
			else if(array[i][j] == 'v'){ array[i][j] = '/'; i++;}
			else break;
		}
		if(array[i][j] == '/'){ cout << "LOOP" << endl; }
		else { cout << j << " " << i << endl; }
	}
	return 0;
}

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

int main(){
  int h, w;
  while(true){
    cin >> h >> w;
    if(h==0 && w==0)
      break;
    vector<string> m;
    int c[h][w];
    string s;
    for(int k=0; k<h; k++){
      cin >> s;
      m.push_back(s);
      for(int l=0; l<w; l++)
	c[k][l] = 0;
    }
    int i=0, j=0;
    bool lp = false;
    while(true){
      if(c[i][j] == 1){
	lp=true; break;
      }
      else if(m[i][j] == '.')
	break;
      else if(m[i][j] == '>'){
	c[i][j] = 1;
	j++;
      }
      else if(m[i][j] == 'v'){
	c[i][j] = 1;
	i++;
      }
      else if(m[i][j] == '<'){
	c[i][j] = 1;
	j--;
      }
      else if(m[i][j] == '^'){
	c[i][j] = 1;
	i--;
      }
    }
    if(lp){
      cout << "LOOP\n";
    }
    else
      cout << j << " " << i << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <set>
using namespace std;
bool 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 '>':
      return calc(field, y + 1, x);
      break;
    case '<':
      return calc(field, y - 1, x);
      break;
    case '^':
      return calc(field, y, x - 1);
      break;
    case 'v':
      return calc(field, y, x + 1);
      break;
    case '.':
      resultx = x;
      resulty = y;
      return true;
  }
}

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

#define REP(i, m, n) for(int i = m; i < static_cast<int>(n); ++i)
int main()
{
    int height, width;
    std::vector<std::string> tile = {">", "<", "^", "v", "."};
    
    while (std::cin >> height >> width) {
        if (height == 0 && width == 0) {
            break;
        }
        
        std::vector< std::vector<std::string> > table;
            
        REP(i, 0, height) {
        table.push_back( std::vector<std::string>() );
            
        REP(j, 0, width) {
            std::string data;
            std::cin >> std::setw(1) >> data;
            table[i].push_back(data);
        }
    }
            
        
        bool flag = true;

        while (flag){
            static int i = 0;
            static int j = 0;
            
            if (table[i][j] == tile[0]) {
                table[i][j] = ",";
                j++;
                continue;
            } else if (table[i][j] == tile[1]) {
                table[i][j] = ",";
                j--;
                continue;
            } else if (table[i][j] == tile[2]) {
                table[i][j] = ",";
                i--;
                continue;
            } else if (table[i][j] == tile[3]) {
                table[i][j] = ",";
                i++;
                continue;
            } else if (table[i][j] == ",") {
                flag = false;
                std::cout << "LOOP" << std::endl;
                i = j = 0;
            } else {
                flag = false;
                std::cout << j << " " << i << std::endl;
                i = j = 0;
            }
        }
    }
    
    return 0;
}