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<bits/stdc++.h>
using namespace std;

int main() {

  int w, h;
  while( cin >> h >> w, w+h ) {
    char room[10][10];
    int t = 0;
    int now_x = 0, now_y = 0;

    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) {
	cin >> room[i][j];
      }
    }

    while(1) {
      if( room[now_y][now_x] == '.' ) break;
      char c = room[now_y][now_x];
      if( c == '>' ) now_x++;
      if( c == '<' ) now_x--;
      if( c == 'v' ) now_y++;
      if( c == '^' ) now_y--;
      t++;
      if( t > w * h ) break;
    }

    if( t > w * h ) cout << "LOOP" << endl;
    else cout << now_x << " " << now_y << endl;
  }
}

C++: #include<iostream>
//#include<algorithm>
#include<string>
#include<vector>
//#include <cstring>
//#include <cstdio>
int main() {
	int a, b;
	while (std::cin >> a >> b, a + b != 0) {
		std::vector<std::vector<char>> ch(a, std::vector<char>(b));
		std::vector<std::vector<char>> ch2(a, std::vector<char>(b,0));
		int x=0, y=0;
		for (int i = 0; i < a; ++i) {
			for (int j = 0; j < b; ++j) {
				std::cin >> ch[i][j];
			}
		}
		while (ch[x][y] != '.') {
			if (ch2[x][y] ==1) { std::cout << "LOOP" << std::endl; break; }
			ch2[x][y]++;
			if (ch[x][y] == '>')y++;
			else if (ch[x][y] == '<')y--;
			else if (ch[x][y] == '^')x--;
			else if (ch[x][y] == 'v')x++;
		}
		if (ch2[x][y] == 0)std::cout << y <<" "<<x<< std::endl;
	}
	return 0;
}

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

using namespace std;

typedef struct{
    int x;
    int y;
}dbint;

dbint move(char c){
    dbint mv;
    switch (c) {
        case '>':
            mv.x=1;
            mv.y=0;
            break;
        case '^':
            mv.x=0;
            mv.y=-1;
            break;
        case '<':
            mv.x=-1;
            mv.y=0;
            break;
        case 'v':
            mv.x=0;
            mv.y=1;
            break;
        default:
            mv.x=10;
            mv.y=10;
            break;
    }
    return mv;
}

int main() {
    int h,w,n=0;
    char c;
    dbint p,mv;
    vector<vector<char>>tiles;
    vector<char> temp;
    while(1){
        cin >> h >> w;
        p.x=0;p.y=0;
        if(h==0&&w==0) break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> c;
                temp.push_back(c);
            }
            tiles.push_back(temp);
            temp.clear();
        }
        while(1){
            mv=move(tiles[p.y][p.x]);
            if(mv.x>1) break;
            p.x+=mv.x;
            p.y+=mv.y;
            n++;
            if(n>h*w+100){
                n=-1;
                break;
            }
        }
        if(n>0) cout << p.x << " " << p.y << endl;
        else    cout << "LOOP" << endl;
        tiles.clear();
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

char H[200][200];

int main() {
	int h, w;
	while (cin >> h >> w, h) {
		rep(i, h)scanf("%s", H[i]);
		int x = 0, y = 0;
		map<P, bool>mp;
		while (1) {
			if (mp[P(x, y)]) {
				puts("LOOP");
				break;
			}
			if (H[x][y] == '.') {
				cout << y << ' ' << x << endl;
				break;
			}
			mp[P(x, y)] = true;
			if (H[x][y] == '>')y++;
			else if (H[x][y] == '<')y--;
			else if (H[x][y] == 'v')x++;
			else x--;
		}
	}
}

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);
        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++: #include<iostream>
#include<string>
using namespace std;

int main(){
  while(true){
    int H,W;
    cin>>H>>W;
    if(W==0&&H==0)break;
    string tiles[H][W];
    bool same_tiles[H][W];
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        same_tiles[i][j]=false;
      }
    }
    string tiles_line;
    for(int i=0;i<H;i++){
      cin>>tiles_line;
      for(int j=0;j<W;j++){
        tiles[i][j]=tiles_line[j];
      }
    }
    int now_x=0,now_y=0;
    while(true){
      if(same_tiles[now_y][now_x]==true){
        cout<<"LOOP"<<endl;
        break;
      }
      same_tiles[now_y][now_x]=true;
      if(tiles[now_y][now_x]==">")now_x++;
      else if(tiles[now_y][now_x]=="<")now_x--;
      else if(tiles[now_y][now_x]=="v")now_y++;
      else if(tiles[now_y][now_x]=="^")now_y--;
      else if(tiles[now_y][now_x]=="."){
        cout<<now_x<<' '<<now_y<<endl;
        break;
      }
    }
  }
}

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

#define MAX_W 100
#define MAX_H 100

char room[MAX_H][MAX_W];
int h, w;

void solve() {
    int x=0, y=0;
    bool loop=false;
    while (room[x][y] != '.' && !loop) {
        if (room[x][y] == 'x') {
            loop = true;
        } else if (room[x][y] == '>') {
            room[x][y] = 'x';
            y = y+1;
        } else if (room[x][y] == '<') {
            room[x][y] = 'x';
            y = y-1;
        } else if (room[x][y] == '^') {
            room[x][y] = 'x';
            x = x-1;
        } else { // room[x][y] == 'v'
            room[x][y] = 'x';
            x = x+1;
        }
    }
    if (loop) {
        std::cout << "LOOP" << std::endl;
    } else {
        std::cout << y << ' ' << x << std::endl;
    }
}

void split(const std::string &str) {
    std::string buf;
    std::stringstream ss(str);
    std::vector<std::string> v;
    while (std::getline(ss, buf, ' ')) {
        v.push_back(buf);
    }
    /*
    h = std::stoi(v[0]);
    w = std::stoi(v[1]);
    */
    std::istringstream(v[0]) >> h;
    std::istringstream(v[1]) >> w;
}

int main() {
    std::string line;
    while (std::getline(std::cin, line)) {
        split(line);
        if (h==0 && w==0) break;

        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                // scanf("%c", &room[i][j]);
                std::cin >> room[i][j];
            }
        }
        solve();
        std::cin.ignore();
    }
}