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>

int w,h;

int d[100][100];
char c;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int main(){
	while( std::cin>>h>>w , (w || h) ){
		memset(d,-1,sizeof(d));
		for(int i=0;i<h;++i){
			for(int l=0;l<w;++l){
				std::cin>>c;
				if( c=='>' )
					d[l][i]=0;
				else if( c=='v' )
					d[l][i]=1;
				else if( c=='<' )
					d[l][i]=2;
				else if( c=='^' )
					d[l][i]=3;
			}
		}
		int Point[2]={0,0};
		while(1){
			if( d[Point[0]][Point[1]] == -1 ){
				break;
			}else if( d[Point[0]][Point[1]] < 4 ){
				int dnum=d[ Point[0] ][ Point[1] ];
				d[Point[0]][Point[1]]=4;
				Point[0]+=dx[ dnum ];
				Point[1]+=dy[ dnum ];
			}else{
				Point[0] = Point[1] = -1;
				break;
			}
		}
		if( Point[0]==-1 && Point[1]==-1 ){
			std::cout<<"LOOP"<<std::endl;
		}else{
			std::cout<<Point[0]<<" "<<Point[1]<<std::endl;
		}
	}
}

C++: #include <iostream>
#include <string>
#include <cstring>
#define MAX 100
using namespace std;

int X,Y;
bool flg[MAX][MAX];
string map[MAX];
int main() {
	while (cin >> Y >> X, X||Y) {
		for (int i=0; i<Y; i++)
			cin >> map[i];

		memset(flg, 0, sizeof(flg));
		int x=0,y=0;
		bool f=true;
		while (f) {
			if (flg[y][x]) { cout << "LOOP\n"; break; }
			flg[y][x] = true;
			switch (map[y][x]) {
				case '>':
					x++; break;
				case 'v':
					y++; break;
				case '<':
					x--; break;
				case '^':
					y--; break;
				case '.':
					cout << x << ' ' << y << endl;
					f = false;
					break;
			}
		}
	}
	return 0;
}

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

int w, h;
int x = 0, y = 0;
char table[MAX_L+1][MAX_L+1];
bool used[MAX_L+1][MAX_L+1];

void forward(char operate) {
    
    switch(operate) {
            case '^':
            y--; break;
            case 'v':
            y++; break;
            case '>':
            x++; break;
            case '<':
            x--; break;
        default: break;
    }
}

void solve() {
    x = 0; y = 0; memset(used, false, sizeof(used));
    while(table[y][x] != '.' && !used[y][x]) {
        //printf("%d %d\n", x, y);
        used[y][x] = true;
        forward(table[y][x]);
    }
    if(used[y][x])
    {
        puts("LOOP");
    } else {
        printf("%d %d\n", x, y);
    }
}

int main(void) {
    while(cin >> h >> w, w|h) {
        for(int r = 0; r < h; r++) {
            for(int c = 0; c < w; c++) {
                cin >> table[r][c];
            }
        }
        solve();
    }
    return(0);
}

C++: #include <stdio.h>
int main(void) {
    int height,width,tile[101][101],i,j;
    char floor[101][101];
    while (1) {
        scanf("%d %d\n",&height,&width);
        if (height==0&&width==0) break;
        for (i=0; i<height; i++) {
            for (j=0; j<width; j++) tile[i][j]=0;
        }
        for (i=0; i<height; i++) scanf("%s",floor[i]);
       i=0,j=0;
        while (floor[i][j]!='.'&&tile[i][j]!=1) {
            tile[i][j]=1;
            if (floor[i][j]=='>') {
                j++;
            } else if (floor[i][j]=='<') {
                j--;
            } else if (floor[i][j]=='^') {
                i--;
            } else {
                i++;
            }
        }
        if (tile[i][j]==0) {
            printf("%d %d\n",j,i);
        } else {
            printf("LOOP\n");
        }
    }
    return 0;
}

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

int main(){
   int a, b, i, j;
   char map[102][102];
   
   while(1){
      cin >> a >> b;
      if(a+b==0) break;
      
      for(i=0; i< a; i++){
         for(j=0; j< b; j++){
            cin >> map[i][j];
         }
      }
      i=0,j=0;
      while(1){
         if(map[i][j]=='.'){
            cout << j << " " << i << endl;
            break;
         }else if(map[i][j]=='#'){
            cout << "LOOP" << endl;
            break;
         }else if(map[i][j]=='>'){
            map[i][j]='#';
            j++;
         }else if(map[i][j]=='<'){
            map[i][j]='#';
            j--;
         }else if(map[i][j]=='^'){
            map[i][j]='#';
            i--;
         }else if(map[i][j]=='v'){
            map[i][j]='#';
            i++;
         }
      }
   }
   return 0;
}