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<string>
using namespace std;
int main(){
  int w,h;
  string a[102];
  while(cin>>w>>h,w){
    for(int i=0;i<102;i++){
      a[i]="";
    }
    for(int i=0;i<w;i++){
      cin>>a[i];
    }
    int x=0,y=0;
    while(true){
      if(a[x][y]=='.'){cout<<y<<' '<<x<<endl;break;}
      else  if(a[x][y]=='o'){cout<<"LOOP"<<endl; break;}
      else if(a[x][y]=='>'){a[x][y]='o'; y++;}
      else if(a[x][y]=='<'){a[x][y]='o'; y--;}
      else if(a[x][y]=='^'){a[x][y]='o'; x--;}
    else if(a[x][y]=='v'){a[x][y]='o'; x++;}
    }
  }
}

C++: #include <iostream>

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){
		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++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
char s[101][102];

int n,m;
void solve()
{
	for(int i= 0 ; i < n; i++) cin>>s[i];
	int x = 0,y = 0;
	while(s[y][x] != '.'){
		char c = s[y][x];
		s[y][x] = '#';
		switch(c){
		case '#':
			puts("LOOP");
			return;
		case '>':
			x++;
			break;
		case '<':
			x--;
			break;
		case 'v':
			y++;
			break;
		case '^':
			y--;
			break;
		}
	}
	printf("%d %d\n",x,y);
}

int main(){
	while(cin>>n>>m,(n||m)){
		solve();
	}
    return 0;
}

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

int m,n,w,h;
char b[102][102];
bool v[102][102];

void dfs(int y,int x){
    if(v[y][x]){
        cout<<"LOOP"<<endl;
        return;
    }
    v[y][x]=1;
    if(b[y][x]=='>'){
        dfs(y,x+1);
        return;
    }
    if(b[y][x]=='v'){
        dfs(y+1,x);
        return;
    }
    if(b[y][x]=='<'){
        dfs(y,x-1);return;
    }
    if(b[y][x]=='^'){
        dfs(y-1,x);return;
    }
    cout<<x<<" "<<y<<endl;
}

int main(){
    while(cin>>h>>w,w||h){
        for(int i=0;i<h;i++)
            cin>>b[i];
        memset(v,0,sizeof(v));
        dfs(0,0);
    }
}

C++: /*
	0104:Magical Tiles
*/
#include	<iostream>
#include	<vector>
#include	<cstdio>

using namespace std;

int main(void) {
	int H, W;
	while(1) {
		cin >> W >> H;
		if(H == 0 && W == 0) {
			break;
		}
		vector< vector<char> > tiles;
		vector< vector<int> > status;
		
		tiles.resize(W + 1);
		status.resize(W + 1);
		for(int i = 0; i < (int)tiles.size(); i++) {
			tiles[i].resize(H + 1);
			status[i].resize(H + 1);
		}
		
		for(int i = 0; i < (int)tiles.size() - 1; i++) {
			for(int j = 0; j < (int)tiles[i].size(); j++) {
				scanf("%c", &tiles[i][j]);
			}
		}
		
		for(int i = 0; i < (int)status.size(); i++) {
			for(int j = 0; j < (int)status[i].size(); i++) {
				status[i][j] = 0;
			}
		}
		
		int a = 0, b = 0;
		while(1) {
			if(tiles[a][b] == '.') {
				cout << b << ' ' << a << endl;
				break;
			}
			else if(status[a][b] == 1) {
				cout << "LOOP" << endl;
				break;
			}
			else {
				status[a][b] = 1;
				
				if(tiles[a][b] == '<') {
					//cout << "MOVE:" << '<' << endl;
					b--;
				}
				else if(tiles[a][b] == '>') {
					//cout << "MOVE:" << '>' << endl;
					b++;
				}
				else if(tiles[a][b] == '^') {
					//cout << "MOVE:" << '^' << endl;
					a--;
				}
				else if(tiles[a][b] == 'v') {
					//cout << "MOVE:" << 'v' << endl;
					a++;
				}
			}
		}
	}
	
	return 0;
}

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

char map[100][100];

int main(){
    int h, w;

    while(cin >> h >> w, h != 0 || w != 0){
        int x, y;
        bool loop = false;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cin >> map[j][i];
            }
        }
        x = 0;
        y = 0;
        for(int i=1; i<=10000; i++){
            if(map[x][y] == '!'){
                loop = true;
                break;
            }
            if(map[x][y] == '.'){
                break;
            }
            if(map[x][y] == '>'){
                map[x][y] = '!';
                x++;
            }
            else if(map[x][y] == '<'){
                map[x][y] = '!';
                x--;
            }
            else if(map[x][y] == 'v'){
                map[x][y] = '!';
                y++;
            }
            else if(map[x][y] == '^'){
                map[x][y] = '!';
                y--;
            }
        }
        if(loop) cout << "LOOP" << endl;
        else cout << x << " " << y << endl;
    }
    return 0;
}

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

#define RIGHT '>'
#define LEFT '<'
#define TOP '^'
#define UNDER 'v'
#define LOOP 'l'
#define END '.'
#define MAX 101

int main(){
    char mp[MAX][MAX];
    int n,m;
    
    while(true){
        cin >> n >> m;
        if(!n&&!m) break;
        
        for(int i = 0 ; i < n ; i++)
            for(int j = 0 ; j < m ; j++)
                cin >> mp[i][j];
        
        int x = 0,y = 0;
        while(true){
            if(mp[x][y]==END){
                cout << y << ' ' << x << endl;
                break;
            }
            if(mp[x][y]==LOOP){
                cout << "LOOP" << endl;
                break;
            }
            
            if(mp[x][y]==RIGHT){
                mp[x][y] = LOOP;
                y++;
            }
            else if(mp[x][y]==LEFT){
                mp[x][y] = LOOP;
                y--;
            }
            else if(mp[x][y]==TOP){
                mp[x][y] = LOOP;
                x--;
            }
            else{
                mp[x][y] = LOOP;
                x++;
            }
        }
    }
    
    return 0;
}