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

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

C++: #include <iostream>

using namespace std;

int main(){

	int h, w;
	char field[1000][1000];
	bool vis[1000][1000];

	while(cin>>h>>w, (h||w)){
			
		for(int i=0; i<h; ++i){
			for(int j=0; j<w; ++j){
				
				vis[i][j]=false;
				cin>>field[i][j];
			}
		}
		
		int x=0, y=0;
		
		while(!vis[y][x] && field[y][x] != '.'){
			
			vis[y][x] = true;

			if(field[y][x]=='>'){
				x += 1;
			}
			else if(field[y][x]=='^'){
				y -= 1;
			}
			else if(field[y][x]=='<'){
				x -= 1;
			}
			else if(field[y][x]=='v'){
				y += 1;
			}

		}
		
		if(vis[y][x]){
			cout << "LOOP" << endl;
		}
		else{
			cout << x << " " << y << endl;
		}
	}

	return 0;
}

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

int main() {
    int X, Y;
    
    while (cin >> X >> Y && X + Y != 0) {
        char room[101][101];
        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;
}