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>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define SZ(n)  (int)n.size()
#define dump(x) cerr<<#x<<" = "<<(x)<<endl;
#define debug(x)cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define MP make_pair
#define PB push_back
	
	char ta[30][30];
	int h,w,ny=0,nx=0,cnt=0;
	bool ok(int y,int x,int ny,int nx){if(ny+y>=0&&ny+y<=h-1&&nx+x>=0&&nx+x<=w-1)return 1;else return 0;}
	int main(){

	while(cin>>h>>w,h+w){
	cnt=0;
	ny=nx=0;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>ta[i][j];
	while(true){
		//cout<<ny<<" "<<nx<<endl;
		if(ta[ny][nx]=='.'){cout<<nx<<" "<<ny<<endl;break;}
		if(cnt>=10000){cout<<"LOOP"<<endl;;break;}
		if(ta[ny][nx]=='>')nx++;
		else if(ta[ny][nx]=='<')nx--;
		else if(ta[ny][nx]=='^')ny--;
		else if(ta[ny][nx]=='v')ny++;
		cnt++;
	}
	for(int i=0;i<30;i++)for(int j=0;j<30;j++)ta[i][j]=' ';
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define o(a) cout<<a<<endl
using namespace std;

int main(){
	int h,w;
	while(1){
		cin>>h>>w;
		if(h==0&&w==0) break;
		char s[101][101];
		//vector<string> s(h);
		rep(i,0,h) rep(j,0,w) cin>>s[i][j];
		int y=0,x=0;
		bool f=0;
		//o(s[0][0]);
		for(int i=0;;i++){
			char c=s[y][x];
			//cout<<c<<endl;
			if(c=='>') x++;
			else if(c=='<') x--;
			else if(c=='^') y--;
			else if(c=='v') y++;
			else if(c=='.'){
				f=1; break;
			}
			//cout<<i<<endl;
			if(i>h*w) break;
		}
		if(f) cout<<x<<" "<<y<<endl;
		else cout<<"LOOP"<<endl;
	}
}

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;
            break;
         }else if(map[i][j]=='#'){
            cout << "loop" << endl;
            break;
         }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++: // 2011/01/07 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int W, H;
		cin >> W >> H;
		if(W==0&&H==0)
			break;

		char til[100][100];
		for(int y=0; y<H; y++)
			for(int x=0; x<W; x++)
				cin >> til[y][x];

		bool flg[100][100];
		for(int y=0; y<H; y++)
			for(int x=0; x<W; x++)
				flg[y][x] = false;

		for(int x=0, y=0; ; ){
			if(flg[y][x]){
				cout << "LOOP" << endl;
				break;
			}

			flg[y][x] = true;

			if(til[y][x]=='>')
				x++;
			else if(til[y][x]=='<')
				x--;
			else if(til[y][x]=='v')
				y++;
			else if(til[y][x]=='^')
				y--;
			else if(til[y][x]=='.'){
				cout << x << ' ' << y << endl;
				break;
			}
		}
	}

	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);
    if(b[y][x]=='v')
        dfs(y+1,x);
    if(b[y][x]=='<')
        dfs(y,x-1);
    if(b[y][x]=='^')
        dfs(y-1,x);
    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++: #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;
		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]=='>'){
				map[now.y][now.x]=='\0';
				now.x++;
			}
			else if(map[now.y][now.x]=='<'){
				map[now.y][now.x]=='\0';
				now.x--;
			}
			else if(map[now.y][now.x]=='v'){
				map[now.y][now.x]=='\0';
				now.y++;
			}
			else if(map[now.y][now.x]=='^'){
				map[now.y][now.x]=='\0';
				now.y--;
			}
			
			if(map[now.y][now.x]=='.'){
				cout<<now.x<<" "<<now.y<<endl;
				break;
			}
			else if(map[now.y][now.x]=='\0'){
				cout<<"LOOP"<<endl;
				break;
			}
		}
	}
}

C++: #include<cstdio>
#include<algorithm>
#include<functional>
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
	int i,j,k,h,w,cnt;
	char mp[101][101];
	while(1) {
		cin>>h>>w;
		if(h==0&&w==0)break;
		for(i=0;i<h;i++) 
			for(j=0;j<w;j++) cin>>mp[i][j];
		cnt=0;
		i=0,j=0;
		while(1) {
			if('>'==mp[i][j]) j++,cnt++;
			if('v'==mp[i][j]) i++,cnt++;
			if('^'==mp[i][j]) i--;cnt++;
			if('<'==mp[i][j]) j--,cnt++;
			if('.'==mp[i][j]) {
				cout<<j<<" "<<i<<endl;
				break;
			}
			if(cnt>10000) {
				cout<<"LOOP"<<endl;
				break;
			}
		}
	}
}

C++: #include<stdio.h>
int main(void)
{
	int h,w;
	int i,j;
	char map[101][101];
	int flg[101][101];
	
	scanf("%d %d",&h,&w);
	while(h!=0 && w!=0){
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				flg[i][j]=0;
			}
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				scanf(" %c",&map[i][j]);
			}
		}
		i=0;
		j=0;
		while(1){
			if(map[i][j]=='.' || flg[i][j]==1){
				break;
			}
			else if(map[i][j]=='>'){
				flg[i][j]=1;
				j++;
			}
			else if(map[i][j]=='<'){
				flg[i][j]=1;
				j--;
			}
			else if(map[i][j]=='^'){
				flg[i][j]=1;
				i--;
			}
			else if(map[i][j]=='v'){
				flg[i][j]=1;
				i++;
			}
		}
		if(flg[i][j]==1){
			printf("LOOP\n");
		}
		else {
			printf("%d %d\n",j,i);
		}
		scanf("%d %d",&h,&w);
	}
	return 0;
}

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

using namespace std;

int H, W;
vector<string> tiles;
bool reached[110][110];

int main() {
	while (1) {
		cin >> H >> W; if (H == 0 && W == 0) break;
		
		tiles.assign(H, "");
		for (int i = 0; i < H; i++) {
			cin >> tiles[i];
		}
		
		memset(reached, 0, sizeof(reached));
		
		int x = 0, y = 0;
		bool loop = false;
		while (tiles[y][x] != '.') {
			if (reached[y][x]) {
				loop = true;
				break;
			}
			reached[y][x] = true;
			char t = tiles[y][x];
			
			if (t == '>') {
				x++;
			}
			if (t == '<') {
				x--;
			}
			if (t == '^') {
				y--;
			}
			if (t == 'v') {
				y++;
			}
		}
		
		if (loop) cout << "LOOP" << endl;
		else cout << x << " " << y << endl;
	}
	
	return 0;
}