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>
using namespace std;

int main(){
   int a, b, i, j;
   char map[102][102]
   
   while(1){
      cin >> a >> b;
      if(a+b==0) break;
      
      for(i=0; i< a; i++){
         for(j=0; j< b; j++){
            cin >> map[i][j];
         }
      }
      i=0;j=0;
      while(1){
         if(map[i][j]=="."){
            cout << i << " " << j << endl;
         }else if(map[i][j]=="#"){
            cout << "loop" << endl;
         }else if(map[i][j]==">"){
            map[i][j]="#";
            j++;
         }else if(map[i][j]=="<"){
            map[i][j]="#";
            j--;
         }else if(map[i][j]=="^"){
            map[i][j]="#";
            i++;
         }else if(map[i][j]=="v"){
            map[i][j]="#";
            i--;
         }
      }
   }
   return 0;
   
   
}

C++: #include <iostream>
#include <string>
using namespace std;
int loop_counter[100][100]={0};
string board[100];
int loop(int y,int x){
	if(loop_counter[y][x]){
		cout<<"LOOP"<<endl;
		return 0;
	}
	loop_counter[y][x]=1;
	if(board[y][x]=='^')
		return loop(y-1,x);
	else if(board[y][x]=='v')
		return loop(y+1,x);
	else if(board[y][x]=='<')
		return loop(y,x-1);
	else if(board[y][x]=='>')
		return loop(y,x+1);
	else if(board[y][x]=='.'){
		cout << x <<" "<<y<<endl;
		return 0;
	}
	return 0;
}
int main(){
	int h,w;
	while(cin >> h >> w){
		if(h==0 && w==0)
			return 0;
		for(int i=0 ; i<h ; i++ )
			cin >> board[i];
		loop(0,0);
	}
}

C++: #include<iostream>
using namespace std;
int main(){
   int H,W;
   char t[101][101];

   while(cin >> H >> W,(H!=0&&W!=0)){
   for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
		cin >> t[j][i];
	}
   }

   int X=0,Y=0;
   for(int k=0;k<10000;k++){
	if(t[X][Y] == '>'){
		X++;
	}else if(t[X][Y] == '<'){
		X--;
	}else if(t[X][Y] == 'v'){
		Y++;
	}else if(t[X][Y] == '^'){
		Y--;
	}else if(t[X][Y] == '.'){
		break;
	}

   }

   if(t[X][Y] == '.'){
	cout << X << " " << Y << endl;
   }else{
	cout << "LOOP" << endl;
   }

   }
   return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
char m[111][111];
bool used[111][111];
char c[] = "v^<>";
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
int main(void){
  while(1){
    int w,h;
    cin >> w >> h;
    if(!w && !h)break; 
    memset(m,0,sizeof(m));
    memset(used,false,sizeof(used));
    for(int i = 0; i < w; i++){
      cin >> m[i];
    }
    int x = 0,y = 0;
    bool f = true;
    while(m[x][y] != '.'){
      used[x][y] = true;
      for(int i = 0;i < 4; i++){
	if(m[x][y] == c[i]){
	  x += dx[i];
	  y += dy[i];
	  break;
	}
      }
      if(used[x][y]){
	cout << "LOOP" << endl;
	f = false;
	break;
      }
    }
    if(f){
      cout << y << " " << x << endl;
    }
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

string data[500];
bool sumi[500][500];
int nx,ny,ansx,ansy;
int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h==0&&w==0) break;
		REP(i,h) cin >> data[i];
		REP(i,500) REP(j,500) sumi[i][j] = false;
		nx = 0; ny = 0;
		bool flg = true;
		sumi[nx][ny] = true;
		while(flg){
			if(data[nx][ny]=='>') ny++;
			if(data[nx][ny]=='<') ny--;
			if(data[nx][ny]=='^') nx--;
			if(data[nx][ny]=='v') nx++;
			if(data[nx][ny]=='.'){
				ansx = nx;
				ansy = ny;
				flg = false;
			}
			if(sumi[nx][ny]&&flg==true){
				ansx = -1;
				flg = false;
			}
			sumi[nx][ny] = true;
		}
		if(ansx==-1) cout << "LOOP" << endl;
		else cout << ansy << " " << ansx << endl;
	}
}

C++: #include<stdio.h>
#include<string.h>

int main(){
	char ss[2][110][111];
	int w,h,i,j,x,y,loop;
	
	while(~scanf("%d%d",&w,&h)){
		if(w==0 && h==0)break;
		
		memset(ss,0,sizeof(ss));
		
		for(i=0;i<h;i++){
			scanf(" %s ",ss[0][i]);
		}
		
		x=0;
		y=0;
		loop=0;
		
		while(1){
			switch(ss[0][y][x]){
			case '>':
				++x;
				loop=ss[1][y][x];
				ss[1][y][x]=1;
				break;
			case '<':
				--x;
				loop=ss[1][y][x];
				ss[1][y][x]=1;
				break;
			case '^':
				--y;
				loop=ss[1][y][x];
				ss[1][y][x]=1;
				break;
			case 'v':
				++y;
				loop=ss[1][y][x];
				ss[1][y][x]=1;
				break;
			}
			
			if(loop)break;
			if(ss[0][y][x]=='.')break;
		}
		
		if(loop==1){
			printf("LOOP\n");
		}else{
			printf("%d %d\n",x,y);
		}
	}
	return 0;
}

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

using namespace std;

int main(){
	int w, h;
	char room[101][101];
	vector< pair<int, int> > visited;
	while(cin >> h >> w, h || w){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> room[i][j];
			}
		}
		visited.push_back(pair<int, int>(0, 0));
		int flag = 1;
		while (flag){
			pair<int, int> tmp;
			switch (room[visited.back().first][visited.back().second])
			{
			case '>':
				tmp.first = visited.back().first;
				tmp.second = visited.back().second + 1;
				visited.push_back(tmp);
				break;
			case '<':
				tmp.first = visited.back().first;
				tmp.second = visited.back().second - 1;
				visited.push_back(tmp);
				break;
			case '^':
				tmp.first = visited.back().first - 1;
				tmp.second = visited.back().second;
				visited.push_back(tmp);
				break;
			case 'v':
				tmp.first = visited.back().first + 1;
				tmp.second = visited.back().second;
				visited.push_back(tmp);
				break;
			case '.':
				cout << visited.back().second << ' ' << visited.back().first << endl;
				flag = 0;
				visited.clear();
				break;
			}
			for (int i = visited.size() - 2; i >= 0; i--){
				if (visited[i] == tmp){
					cout << "LOOP" << endl;
					flag = 0;
					break;
				}
			}
		}
	}
	return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,i,j,f,g,c[500][500],v;
	char z[1000][1000],x;
	while(1){
		v=0;
		scanf("%d %d",&a,&s);
		if(a==0&&s==0)	break;
		for(i=0;i<a;i++){
			scanf("%s",z[i]);
		}
		for(i=0;i<s;i++){
			for(j=0;j<a;j++){
				c[i][j]=0;
			}
		}
		f=0;
		g=0;
		while(1){
			if(z[f][g]=='>'){
				g++;
				c[f][g]++;
			}
			else if(z[f][g]=='<'){
				g--;
				c[f][g]++;
			}
			else if(z[f][g]=='^'){
				f--;
				c[f][g]++;
			}
			else if(z[f][g]=='v'){
				f++;
				c[f][g]++;	
			}
			if(z[f][g]=='.')	break;
			if(c[f][g]==2){
				v=1;
				break;
			}
		}
		if(v==1)
			printf("LOOP\n");
		else
			printf("%d %d\n",g,f);
	}
		return 0;
}