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<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>


using namespace std;

void Solution()
{
    int sideH, sideW;
    
    char cha[101][101];
    
    int masu;
    int x, y; //in this problem y axis is sideH, x axis is sideW
    
    while (cin>>sideH>>sideW)
    {
        if (sideW == 0 && sideH == 0)
        {
            break;
        }
        
        for (y = 0; y < sideH; y++) //save the data to array
        {
            cin>>cha[y];
        }
        
        masu = x = y = 0; // start from 0, 0
        
        while (true)
        {
            if (cha[y][x] == '.')
            {
                cout<<x<<" "<<y<<endl;
                break;
            }
            
            switch (cha[y][x]) // walk automatically by symbol
            {
                case '^':
                    y--;
                    break;
                case '<':
                    x--;
                    break;
                case 'v':
                    y++;
                    break;
                case '>':
                    x++;
                    break;
            }
            
            masu++;
            
            if (masu > sideH * sideW) // means infinite loop, or out of the limit
            {
                cout<<"LOOP"<<endl;
                break;
            }
        }
    }

}

int main()
{
    Solution();
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

#define MP make_pair<int,int>

int mp[830][252];
bool vstd[830][252];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int dw[255];

int main(){
  dw['.'] = -1;
  dw['>'] = 0;
  dw['<'] = 2;
  dw['v'] = 1;
  dw['^'] = 3;
  while(true){
    int h,w;
    cin>>h>>w;
    if(!(h+w))break;
    REP(i,h)REP(j,w)vstd[i][j] = false;
    REP(i,h){
      string s;
      cin>>s;
      REP(j,w) mp[i][j] = dw[s[j]];
    }
    int x,y;
    x=y=0;
    while(mp[y][x]!=-1){
      if(vstd[y][x]){
        x=y=-1;
        break;
      }
      vstd[y][x] = true;
      int c = mp[y][x];
      x += dx[c];
      y += dy[c];
    }
    if(x==-1){
      cout<<"LOOP"<<endl;
    }else{
      printf("%d %d\n",x,y);
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  while(cin>>H>>W,H+W!=0){
    string tile[H];
    for(int i=0;i<H;i++)
      cin>>tile[i];
    if(tile[0][0]=='.'){
      cout<<"0 0"<<endl;
      continue;
    }
    int i=0;
    pair<int,int> now=make_pair(0,0);
    while(i!=10001){
      i++;
      if(i==10000)
	cout<<"LOOP"<<endl;
      if(tile[now.first][now.second]=='.'){
	cout<<now.first<<" "<<now.second<<endl;
	break;
      }else if(tile[now.first][now.second]=='>')
	now.second++;
      else if(tile[now.first][now.second]=='<')
	now.second--;
      else if(tile[now.first][now.second]=='v')
	now.first++;
      else if(tile[now.first][now.second]=='^')
	now.first--;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int *array1, *array2, n, m, tmp, i, j;
	char w;
	
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0){
			break;
		}
		
		array1 = (int *)calloc(n*m, sizeof(int));
		array2 = (int *)calloc(n*m, sizeof(int));
		
		for(i = 0; i < n; i++){
			for(j = 0, tmp = i*m; j < m; j++){
				cin >> w;
				
				if(w == '>'){
					array1[tmp+j] = tmp + j + 1;
				} else if(w == 'v'){
					array1[tmp+j] = tmp + j + m;
				} else if(w == '<'){
					array1[tmp+j] = tmp + j -1;
				} else if(w == '^'){
					array1[tmp+j] = tmp + j - m;
				} else {
					array1[tmp+j] = -1;
				}
			}
		}
		
		tmp = array1[0];
		array2[0] = 1;
		while(1){
			if(array2[tmp] == 1){
				cout << "LOOP" << endl;
				break;
			} else if(array1[tmp] == -1){
				i = tmp % m;
				j = (int)(tmp / m);
				cout << i << " " << j << endl;
				break;
			}
			
			array2[tmp] = 1;
			tmp = array1[tmp];
		}		
		
		free(array1);
		free(array2);
	}
	
	
	return 0;
}

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

struct zahyou{
	int x;
	int y;
};

int main(){
	
	int tx,ty,count;
	char map[100][100];
	bool flag;
	struct zahyou now;
	
	
	
	while(cin>>tx>>ty,tx&&ty){
		
		flag=false;
		now.x=0;
		now.y=0;
		count=0;
		memset(map,'\0',sizeof(map));
		
		for(int i=0;i<ty;i++){
			for(int j=0;j<tx;j++){
				cin>>map[i][j];
			}
		}
		
		while(1){
			if(map[now.y][now.x]=='>'){
				if(map[now.y][now.x+1]=='<'){
					flag=true;
				}
				else{
					now.x++;
				}
			}
			else if(map[now.y][now.x]=='<'){
				if(map[now.y][now.x-1]=='>'){
					flag=true;
				}
				else{
					now.x--;
				}
			}
			else if(map[now.y][now.x]=='v'){
				if(map[now.y+1][now.x]=='^'){
					flag=true;
				}
				else{
					now.y++;
				}
			}
			else if(map[now.y][now.x]=='^'){
				if(map[now.y-1][now.x]=='v'){
					flag=true;
				}
				else{
					now.y--;
				}
			}
			count++;
			
			if(count>tx*ty){
				flag=true;
			}
			
			if(map[now.y][now.x]=='.' || flag){
				if(flag){
					cout<<"LOOP"<<endl;
				}else{
					cout<<now.x<<" "<<now.y<<endl;
				}
				break;
			}
		}
	}
}

C++: #include<iostream>
using namespace std;
char a[10000][10000]; int h, w, loop, cx, cy;
int main() {
	while (true) {
		cin >> h >> w;
		if (!h) { break; }
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> a[i][j];
			}
		}
		cx = 0; cy = 0;
		while (true) {
			if (loop < 10000000) { cout << "LOOP" << endl; break; }
			if (a[cy][cx] == '.') { cout << cx << ' ' << cy << endl; break; }
			if (a[cy][cx] == '<') { cx--; }
			if (a[cy][cx] == '>') { cx++; }
			if (a[cy][cx] == '^') { cy--; }
			if (a[cy][cx] == 'v') { cx++; }
			loop++;
		}
	}
}