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

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
	char d[101][101];
	int w,h,k,x,y;
	while(cin >> h >> w) {
		if (w+h==0) break;
		for (y=0;y<h;y++) cin >> d[y];
		x=0; y=0; k=0;
		while(true) {
			if (d[y][x]=='.') { cout << x << " " << y << endl; break;}
			switch(d[y][x]) {
				case '<':  x--; break;
				case '>':  x++; break;
				case '^':  y--; break;
				case 'v':  y++; break;
			}
			k++;
			if (k>w*h) {cout << "LOOP" << endl; break;}
		}
	}
    return 0;
	}

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

using namespace std;

void  move(char t[100][100][2], int *x, int *y) {
  t[*y][*x][1] = 1;
  if (t[*y][*x][0] == '>')
    (*x)++;
  else if (t[*y][*x][0] == '<')
    (*x)--;
  else if (t[*y][*x][0] == '^')
    (*y)--;
  else if (t[*y][*x][0] == 'v')
    (*y)++;
}

int main(int argc, char *argv[]) {
  int h, w;
  char tile[100][100][2];
  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0)
      break;

    string tmp;
    // skip '\n'                                                                                                                                                                                            
    getline(cin, tmp);
    for (int i = 0; i < h; i++) {
      getline(cin, tmp);
      for (int j = 0; j < w; j++) {
        tile[i][j][0] = tmp[j];
        tile[i][j][1] = 0;
      }
    }
    /*                                                                                                                                                                                                      
    for (int i = 0; i < h; i++) {                                                                                                                                                                           
      for (int j = 0; j < w; j++)                                                                                                                                                                           
        cout << tile[i][j][0];                                                                                                                                                                              
      cout << endl;                                                                                                                                                                                         
    }                                                                                                                                                                                                       
    */
    int x = 0, y = 0;
    while (true) {
      move(tile, &x, &y);
      /*                                                                                                                                                                                                    
      cout << x << ' ' << y << endl;                                                                                                                                                                        
      */
      if (tile[y][x][0] == '.') {
        cout << x << ' ' << y << endl;
        break;
      } else if (tile[y][x][1] > 0) {
        cout << "LOOP" << endl;
        break;
      }
    }
  }
  return 0;
}

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

int main(){
  while(1){
    int h,w;
    scanf(" %d %d",&h,&w);
    if(h==0 && w==0)break;

    char mp[102][102];
    int flag[102][102]={0};
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)scanf(" %c",&mp[i][j]);
    }

    int nh=0,nw=0;
    while(mp[nh][nw]!='.' && flag[nh][nw]==0){
      flag[nh][nw]=1;
      if(mp[nh][nw]=='>')nw++;
      if(mp[nh][nw]=='<')nw--;
      if(mp[nh][nw]=='^')nh--;
      if(mp[nh][nw]=='v')nh++;
      
    }

    if(flag[nh][nw])printf("LOOP\n");
    else printf("%d %d\n",nw,nh);

  }
  return(0);
}

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

int main() {
    int X, Y;
    
    while (cin >> X >> Y && X + Y != 0) {
        char room[20][20];
        for (int x = 0; x < X; ++x) {
            for (int y = 0; y < Y; ++y) {
                cin >> room[x][y];
            }
        }

        int steps = 0;
        int x = 0, y = 0;
        while (room[x][y] != '.' && steps < 10000) {
            if (room[x][y] == '>') {
                y++;
            }
            if (room[x][y] == '<') {
                y--;
            }
            if (room[x][y] == '^') {
                x--;
            }
            if (room[x][y] == 'v') {
                x++;
            }
            steps++;
        }
        if (steps >= 10000) {
            cout << "LOOP" << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }
    return 0;
}