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>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

using namespace std;

#define all(c) c.begin(),c.end()
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& val){
    os << "[ ";
    for(typename vector<T>::const_iterator it=val.begin();
        it != val.end();++it){
        os << *it << " ";
    }
    os << "]";
    return os;
}
vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,-1,0,1};

inline int mc(char c){
// '>' (大なり記号): 東向きの矢印が書かれたタイル
// '<' (小なり記号): 西向きの矢印が書かれたタイル
// '^' (べき記号) : 北向きの矢印が書かれたタイル
// 'v' (小文字ブイ): 南向きの矢印が書かれたタイル
// '.' (ピリオド) : 何も書かれていないタイル
    switch(c){
    case '>':
        return 0;
    case '<':
        return 2;
    case '^':
        return 1;
    case 'v':
        return 3;
    case '.':
        return -1;
    }
    return -1;
}

string solve(vector<string> field){

    int W = field[0].size();
    int H = field.size();
    vector<vector<char> > alr(H,vector<char>(W,false));

    int nx = 0;
    int ny = 0;
    while(mc(field[ny][nx]) != -1){
        if(alr[ny][nx]){
            return "LOOP";
        }
        alr[ny][nx] = true;
        int d = mc(field[ny][nx]);
        ny += dy[d];
        nx += dx[d];
    }
    stringstream ss;
    ss << nx << " " << ny;
    return ss.str();
}
int main(){
    while(true){
        int W,H;
        cin >> H >> W;
        if(W == 0 and H == 0) break;
        vector<string> field(H);
        for(int i=0;i<H;i++){
            cin >> field[i];
        }
        cout << solve(field) << endl;
    }
    return 0;
}

C++: #include <stdio.h>
int main(){
    while (1) {
        int h,w,f=0;
        scanf("%d %d",&h,&w);
        if(h==0&&w==0) return 0;
        char c[h][w];
        int i,x=0,y=0;
        for (i=0; i<h; i++) scanf("%s",c[i]);
        while (1) {
            switch (c[y][x]) {
                case '>':
                    c[y][x]='X';
                    x++;
                    break;
                    
                case '<':
                    c[y][x]='X';
                    x--;
                    break;
                    
                case '^':
                    c[y][x]='X';
                    y--;
                    break;
                    
                case 'v':
                    c[y][x]='X';
                    y++;
                    break;
                    
                case '.':
                    f=1;
                    printf("%d %d\n",x,y);
                    break;
                    
                case 'X':
                    f=1;
                    printf("LOOP\n");
                    break;
            }
            if(f) break;
        }
    }
}

C++: #include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int loop_counter[100][100]={0};
string board[100];
int loop(int y,int x){

	if(loop_counter[y][x]){
		cout<<"LOOP"<<endl;
		return 0;
	}
	loop_counter[y][x]=1;
	if(board[y][x]=='^'){
		return loop(y-1,x);
	}
	else if(board[y][x]=='v'){
		return loop(y+1,x);
	}
	else if(board[y][x]=='<'){
		return loop(y,x-1);
	}
	else if(board[y][x]=='>'){
		return loop(y,x+1);
	}
	else if(board[y][x]=='.'){
		cout << x <<" "<<y<<endl;
		return 0;
	}
	return 0;
}
int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h==0 && w==0)
			return 0;
		for(int i=0 ; i<h ; i++ )
			cin >> board[i];
		loop(0,0);
	}
}

C++: #include<stdio.h>
int a,b,limx,limy;
char s[102][102];
int pass[102][102];
void check(int x,int y){
    if(pass[x][y]!=1){
        a=x,b=y;
        pass[x][y]=1;
        if(s[x][y]=='^'&&x-1>=0)
        check(x-1,y);
        if(s[x][y]=='v'&&x+1<=limx)
        check(x+1,y);
        if(s[x][y]=='>'&&y+1<=limy)
        check(x,y+1);
        if(s[x][y]=='<'&&y-1>=0)
        check(x,y-1);
    }
    else
    a=-1;
}
main(){
    int x,y,i,j;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)
        break;
        limx=x;limy=y;
        for(i=0;i<x;i++)
        for(j=0;j<y;j++)
        pass[x][y]=0;
        for(i=0;i<x;i++)
        scanf("%s",&s[i]);
        check(0,0);
        if(a!=-1)
        printf("%d %d\n",b,a);
        else
        printf("LOOP\n");
    }
}

C++: int main(int argc, char **argv)
{
	int h, w;
	int x = 0, y = 0;
	char tiles[100][100];
	bool throughed[100][100] = {};
	bool loop = false;
	bool end = false;
	while(std::cin >> h >> w, h+w != 0){
		x = 0;
		y = 0;
		for(int i = 0; i < 100; i++){
			for(int j = 0; j < 100; j++){
				throughed[j][i] = false;
			}
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				std::cin >> tiles[j][i];
			}
		}
		while(true){
			if(throughed[x][y]){
				loop = true;
				break;
			}
			throughed[x][y] = true;
			switch(tiles[x][y]){
				case '.':
					end = true;
					break;
				case '^':
					y--;
					break;
				case 'v':
					y++;
					break;
				case '<':
					x--;
					break;
				case '>':
					x++;
					break;
			}
			if(end){
				break;
			}
		}
		if(loop){
			std::cout << "LOOP" << std::endl;
		}else{
			std::cout << x << " " << y << std::endl;
		}
	}
	return 0;
}

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

int x, y, d, HW, H, W;
string input[100];
bool orLoop[100][100];

bool loop(int a, int b){
	if(orLoop[b][a]){
		return true;
	}
	char i = input[b][a];
	if(i=='>'){
		orLoop[b][a] = true;
		if(loop(a + 1, b)){
			return true;
		}
		else
			return false;
	}
	else if(i=='v'){
		orLoop[b][a] = true;
		if(loop(a, b + 1)){
			return true;
		}
		else
			return false;
	}
	else if(i=='<'){
		orLoop[b][a] = true;
		if(loop(a - 1, b)){
			return true;
		}
		else
			return false;
	}
	else if(i=='^'){
		orLoop[b][a] = true;
		if(loop(a, b - 1)){
			return true;
		}
		else
			return false;
	}
	else{
		x = a;
		y = b;
		return false;
	}
}

int main(){
	while(cin >> H >> W){
		if (H == 0 && W == 0) { break; }
		else { HW = H*W + 2; }

		for (int i = 0; i < 100;i++){
			for (int j = 0; j < 100;j++){
				orLoop[i][j] = false;
			}
		}
			for (int i = 0; i < H; i++)
			{
				cin >> input[i];
			}
		if(loop(0, 0)){
			cout << "LOOP" << endl;
		}
		else{
			cout << x << " " << y << endl;
		}
	}
	return 0;
}