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

int main(void)
{
	while(1) {
		char point[100][100];
		bool check[100][100], ep = false;
		int Y, X;
		int x, y;

		for(int i = 0; i < 100; i++) {
			for(int j = 0; j < 100; j++) {
				point[i][j] = '.';
				check[i][j] = false;
			}
		}

		cin >> Y >> X;

		if(Y == 0 && X == 0) break;

		for(int i = 0; i < Y; i++) {
			for(int j = 0; j < X; j++) {
				cin >> point[j][i];
			}
		}

		x = 0, y = 0;

		while(1) {
			if(check[x][y] == true) {
				cout << "LOOP" << endl;
				break;
			} else {
				check[x][y] = true;

				switch(point[x][y]) {
				case '>' : x += 1; break;
				case '<' : x -= 1; break;
				case '^' : y -= 1; break;
				case 'v' : y += 1; break;
				case '.' : ep = true; break;
				};

				if(ep == true) {
					cout << x << " " << y << endl;
					break;
				}
			}
		}
	}
	return 0;
}

C++: #include<iostream>

void move(int, int);

char tiles[100][100];
bool mem[100][100];

int main()
{
  int H, W;
  while(true)
  {
    std::cin >> H >> W;
    if(!H && !W)
      break;
    for(int i = 0; i < 10000; i++)
      mem[i / 100][i % 100]  = 0;

    for(int i = 0; i < H; i++)
      std::cin >> tiles[i];

    move(0, 0);
  }
  return 0;
}

void move(int x, int y)
{
  if(mem[y][x])
  {
    std::cout << "LOOP" << std::endl;
    return;
  }

  mem[y][x] = true;

  switch(tiles[y][x])
  {
    case '<':
      move(x - 1, y);
      return;
    case '>':
      move(x + 1, y);
      return;
    case '^':
      move(x, y - 1);
      return;
    case 'v':
      move(x, y + 1);
      return;
    case '.':
      std::cout << x << " " << y << std::endl;
      return;
  }
}

C++: #include <iostream>
#include <cstring>
#include <string>

#define loop for (;;)
#define repeat(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
  loop {
    int H, W;
    cin >> H >> W;
    if (!H && !W) return 0;
    string room[H];
    bool visited[H][W];
    memset(visited, 0, sizeof visited);
    int x = 0, y = 0;
    repeat(i, H)
      cin >> room[i];
    for (bool finish = false; !finish;) {
      if (visited[y][x]) {
        cout << "LOOP" << endl;
        finish = true;
      } else
        visited[y][x] = true;
      switch (room[y][x]) {
      case '>': x++; break;
      case '<': x--; break;
      case '^': y--; break;
      case 'v': y++; break;
      case '.':
        cout << x << ' ' << y << endl;
        finish = true;
        break;
      default: break;
      }
    }
  }
}

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

int main(){
    int w,h;
    int ichi[101][101]={0};
    while(1){
        int i=0,j=0;
        cin >> w >> h;
        if(w == 0 && h == 0){
            break;
        }
        char map[w][h];
        for(int n=0;n<w;n++){
            for(int k=0;k<h;k++){
                cin >> map[n][k];
            }
        }
        while(1){
            for(int n=0;n<w;n++){
                memset(ichi[n],0,sizeof(ichi[i]));
            }
            if(ichi[i][j] == 1){
                cout << "LOOP" << endl;
                break;
            }
            else if(map[i][j] == '.'){
                cout << j << " " << i << endl;
                break;
            }
            if(map[i][j] == '>'){
                ichi[i][j] = 1;
                j++;
            }
            else if(map[i][j] == '<'){
                ichi[i][j] = 1;
                j--;
            }
            else if(map[i][j] == '^'){
                ichi[i][j] = 1;
                i--;
            }
            else if(map[i][j] == 'v'){
                ichi[i][j] = 1;
                i++;
            }
        }
    }

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<vector>
#include<cstdio>
#include<climits>
#include<cfloat>
#include<cstring>
#define foreach(t,p) for(t::iterator it=p.begin();it!=p.end();++it)
#define rforeach(t,p) for(t::reverse_iterator it=p.rbegin();it!=p.rend();++it)
#define all(p) p.begin(),p.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define FOREACH(t,p,tit) for(t::iterator tit=p.begin();tit!=p.end();++tit)
using namespace std;
char tiles[110][110];

int main()
{
    int w,h;
    while(cin >> h >> w)
    {
        memset(tiles,'.',sizeof(tiles));
        if(w==0&&h==0){break;}
        rep(j,h)rep(i,w){cin >> tiles[i][j];}

        int x,y,nextx,nexty;
        x=0;
        y=0;
        int loop = 0;
        char nowtile;
        while(1)
        {
            nowtile = tiles[x][y];
            tiles[x][y] = 'x';
            if(nowtile=='x'){loop=1;break;}
            if(nowtile=='.'){break;}
            if(nowtile=='>'){x++;continue;}
            if(nowtile=='<'){x--;continue;}
            if(nowtile=='v'){y++;continue;}
            if(nowtile=='^'){y--;continue;}

        }
        if(loop){cout << "LOOP"<<endl;continue;}
        //cout <<x << " "<<y << endl;
        printf("%d %d\n",x,y);
    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,m;
  while(cin >>n>>m,n||m){
    cin.ignore();
    int field[101][101] = {0},x = 0,y = 0;
    bool check[101][101] = {false};
    for(int i=0; i<n; i++){
      for(int j=0; j<m; j++){
	char c;
	scanf("%c",&c);
	if(c == '>'){field[j][i] = 1;}
	if(c == '<'){field[j][i] = 2;}
	if(c == '^'){field[j][i] = 3;}
	if(c == 'v'){field[j][i] = 4;}
      }
      scanf("%*c");
    }
    for(;;){
      if(check[x][y]){x = -1;cout <<"LOOP"<<endl;break;}
      check[x][y] = true;
      if(!field[x][y]){break;}
      else if(field[x][y] == 1){x++;}
      else if(field[x][y] == 2){x--;}
      else if(field[x][y] == 3){y--;}
      else if(field[x][y] == 4){y++;}
    }
    if(x>=0){cout <<x<<" "<<y<<endl;}
  }
  return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
char a[1000][1000]; int h, w, loop, cx, cy;
int main() {
	while (true) {
		cin >> h >> w;
		if (!h) { break; }
		memset(a, ' ', sizeof(a));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> a[i][j];
			}
		}
		cx = 0; cy = 0; loop = 0;
		while (true) {
			if (loop > 20000000) { cout << "LOOP" << endl; break; }
			if (a[cy][cx] == '.') { cout << cx << ' ' << cy << endl; break; }
			if (a[cy][cx] == '<') { cx--; }
			if (a[cy][cx] == '>') { cx++; }
			if (a[cy][cx] == '^') { cy--; }
			if (a[cy][cx] == 'v') { cy++; }
			loop++;
		}
	}
}