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)
		}
	}
}

Python: import sys
import math

def decide_move(x,y,tile,check):
	if tile == '<':
		x -= 1
		check[x][y] += 1
		return x,y,check
	elif tile == '>':
		x += 1
		check[x][y] += 1
		return x,y,check
	elif tile == '^':
		y -= 1
		check[x][y] += 1
		return x,y,check
	else:
		y += 1
		check[x][y] += 1
		return x,y,check


while True:
	h,w = map(int,input().split())
	if h == 0:
		break
	tile_map = []
	for i in range(h):
		tile_map[i] = input()
	check =[[0 for i in range(w)]for j in range(h)]
	check[0][0] = 1
	x = 0
	y = 0
	status = 0

	while True:
		if tile_map[x][y] == '.':
			status = 1
			print(y,x)
			break
		x,y,check = decide_move(x,y,tile_map[x][y],check)
		if check[x][y] > 1:
			status = 1
			print('LOOP')
			break

Python: while True:
    h, w = [int(x) for x in input().split()]
    if h == w == 0:
        break
    bool_ = [[0 for x in range(w)] for y in range(h)]
    tile = []
    for i in range(h):
        tile.append(list(input()))
    x, y = 0, 0
    while True:
        if bool_[y][x]:
            print('LOOP')
            break
        else:
            bool_[y][x] = 1
            if tile[y][x] == '>':
                x += 1
            elif tile[y][x] == '<':
                x -= 1
            elif tile[y][x] == '^':
                y -= 1
            elif tile[y][x] == 'v':
                y += 1
            elif tile[y][x] == '.':
                print(x, y)
                break

Python: posX,posY=0,0
H,W=map(int,input().split())
while not(H==W==0):
    tile=[[False for i in range(W)] for j in range(H)]
    tileinfo=[['' for i in range(W)] for j in range(H)]
    for i in range(H):
        tileinfo[i]=input().rstrip()
    while True:
        if tileinfo[posX][posY]=='>':
            posX+=1
            continue
        elif tileinfo[posX][posY]=='<':
            posX-=1
            continue
        elif tileinfo[posX][posY]=='v':
            posY+=1
            continue
        elif tileinfo[posX][posY]=='^':
            posY-=1
            continue
        elif tileinfo[posX][posY]=='.':
            print('{} {}'.format(posX,posY))
            break
        if tile[posX][posY]==True:
            print('LOOP')
            break
        else:
            tile[posX][posY]=True

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

int main(void) {
  int H, W;
  while (cin >> H >> W, 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<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

int A = 0, B = 0, C = 0, K = 0, S = 0, T = 0, W = 0, N = 0,H = 0;
int n = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string c;
string sA, strB;
vector<vector<char>> map;
vector<int> population;


void input() {
	CI W >> H;
	
	map.resize(W);
	REP(i, W) {
		map[i].resize(H);
	}
	REP(i, W) {
		REP(j, H) {
			CI map[i][j];
		}
	}
}

void proce() {
	int posn[2] = { 0,0 };
	vector<vector<bool>> check(W, vector<bool>(H, false));
	

	while (map[posn[0]][posn[1]] != '.') {
		check[posn[0]][posn[1]] = true;
		if (map[posn[0]][posn[1]] == '>') {
			posn[1]++;
		}
		else {
			if (map[posn[0]][posn[1]] == 'v') {
				posn[0]++;
			}
			else {
				if (map[posn[0]][posn[1]] == '<') {
					posn[1]--;
				}
				else {
					if (map[posn[0]][posn[1]] == '^') {
						posn[0]--;
					}
				}
			}
		}
		if (check[posn[0]][posn[1]] == true) {
			CO "LOOP" E
			return;
		}
	}
	CO posn[1] << " " << posn[0] E


}

int main(void) {
	
	while (true) {
		input();
		if (W == 0 && H == 0) {
			break;
		}
		proce();
	}

	return 0;
}

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

using namespace std;

int main() {
  int h, w;
  while (cin >> h >> w, h) {
    vector<vector<string>> map(h, vector<string>(w));

    for (auto &seq : map) {
      for (auto &v : seq) {
        char c;
        cin >> c;
        v = c;
      }
    }

    int cx = 0;
    int cy = 0;
    while (true) {
      string str = map[cy][cx];
      map[cy][cx] = "0";
      if (str == ">") {
        ++cx;
      } else if (str == "<") {
        --cx;
      } else if (str == "^") {
        --cy;
      } else if (str == "v") {
        ++cy;
      } else if (str == ".") {
        cout << cx << " " << cy << endl;
        break;
      } else if (str == "0") {
        cout << "LOOP" << endl;
        break;
      }
    }
  }
}

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

int main() {
	int a, b;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		char data[102][102];
		int bb[a][b] = { 0 };
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				cin >> data[i][j];
			}
		}

		int H = 0, W = 0;
		int loop = 0;
		while (1) {
			if (data[H][W] == '<') {
				bb[H][W] = 1;
				W -= 1;
				if (bb[H][W] == 1) {
					loop = 1;
					break;
				}

			} else if (data[H][W] == '>') {
				bb[H][W] = 1;
				W += 1;
				if (bb[H][W] == 1) {
					loop = 1;
					break;
				}
			} else if (data[H][W] == 'v') {
				bb[H][W] = 1;
				H += 1;
				if (bb[H][W] == 1) {
					loop = 1;
					break;
				}
			} else if (data[H][W] == '^') {
				bb[H][W] = 1;
				H -= 1;
				if (bb[H][W] == 1) {
					loop = 1;
					break;
				}
			} else {
				break;
			}
		}
		if (loop != 1) {
			printf("%d %d\n", W, H);
		} else {
			printf("LOOP\n");
		}
	}
	return 0;
}