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];
         }
      }
      for(i=0; i< a; i++){
         for(j=0; j< b; j++){
            cout << map[i][j];
         }
         cout << endl;
      }
      cout << endl;
      i=0,j=0;
      while(1){
         if(map[i][j]=='.'){
            cout << j << " " << i << 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++: #include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main() {
	
	int w,h;
	int *tile;
	int tmp;
	int x,y;
	
	while(cin>>h>>w,w||h){
		tile = new int[w*h];
		x=y=0;
		
		for(int i=0;i<w*h;++i){
			tmp = getchar();
			if(tmp == '\n'){--i;continue;}
			tile[i] = tmp;
		}
		
		while(1){
			
			if(tile[x+y*w] == 0){
				cout<<"LOOP"<<endl;
				break;
			}
			
			if(tile[x+y*w] == '.'){
				cout<<x<<" "<<y<<endl;
				break;
			}
			
			tmp = tile[x+y*w];
			
			tile[x+y*w] = 0;
			
			
			switch(tmp){
				
				case '>':
				++x;
				break;
				
				case '<':
				--x;
				break;
				
				case '^':
				--y;
				break;
				
				case 'v':
				++y;
				break;
			}
		}
	}

	delete[]tile;
	
	return 0;
}

C++: #include<iostream>
using namespace std;
#define UUI long long int
UUI x,y,n,m;
char tile[120][120],a;
int main(){
    while(1){
            cin >> n >> m;
            if(n==0&&m==0)break;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a;
            tile[i][j]=a;
        }
    }
    x=0;
    y=0;
    for(int i=0;i<11000;i++){
            if(tile[y][x]==0){
                    cout << "LOOP" << endl;
                    break;
            }
    if(tile[y][x]=='>'){
        tile[y][x]=0;
        x=x+1;
    }else if(tile[y][x]=='<'){
        tile[y][x]=0;
        x=x-1;
    }else if(tile[y][x]=='^'){
        tile[y][x]=0;
        y=y-1;
    }else if(tile[y][x]=='v'){
        tile[y][x]=0;
        y=y+1;
    }else if(tile[y][x]=='.'){
            cout << y <<" "<< x << endl;
        break;
    }
    }
      for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            tile[i][j]=0;
        }
    }
    }
return 0;
}

C++: #include <stdio.h>
#include <queue>
using namespace std;
typedef pair<int,int> P;

int main()
{
	int x,y;
	char map[100][101];
	bool visited[100][100];
	char mapkind[5] = {"><^v"};
	int tx[4] = {1,-1,0,0},ty[4] = {0,0,-1,1};
	queue<P> que;
	P now;

	scanf("%d%d",&y,&x);

	while(x != 0 && y != 0){
		for(int i = 0; i < y; i++){
			for(int j = 0; j < x; j++){
				visited[i][j] = false;
			}
		}
		for(int i = 0; i < y; i++){
			scanf("%s",map[i]);
		}

		now.first = 0; now.second = 0;
		que.push(now);

		while(!que.empty()){
			now = que.front();
			for(int i = 0; i < 4; i++){
				if(map[now.second][now.first] == mapkind[i]){
					if(now.second + ty[i] >= 0 && now.second + ty[i] < y 
					&& now.first + tx[i] >= 0 && now.first + tx[i] < x
					&& !visited[now.second + ty[i]][now.first + tx[i]] ){
						visited[now.second + ty[i]][now.first + tx[i]] = true;
						now.second += ty[i];
						now.first += tx[i];
						que.push(now);
						break;
					}
				}
			}
			que.pop();
		}

		if(map[now.second][now.first] == '.'){
			printf("%d %d\n",now.first,now.second);
		}
		else{
			printf("Loop\n");
		}

		scanf("%d%d",&y,&x);
	}
	
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
int main() {
 
  int w, h;
  while( cin >> h >> w, w+h ) {
    char room[101][101];
    bool flag[101][101];
    int now_x = 0, now_y = 0;
 
    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) {
    cin >> room[i][j];
    flag[i][j] = false;
      }
    }
 
    while(1) {
      if( flag[now_y][now_x] || room[now_y][now_x] == '.' ) break;
      char c = room[now_y][now_x];
      flag[now_y][now_x] = true;
      
 
      if( c == '>' ) {
    while( room[now_y][now_x] == c ) {
      now_x++;
    }
      }
      if( c == '<' ) {
    while( room[now_y][now_x] == c ) {
      now_x--;
    }
      }
      if( c == 'v' ) {
    while( room[now_y][now_x] == c ) {
      now_y++;
    }
      }
      if( c == '^' ) {
    while( room[now_y][now_x] == c ) {
      now_y--;
    }
      }
    }
 
    if( room[now_y][now_x] != '.' ) cout << "LOOP" << endl;
    else cout << now_x << " " << now_y << endl;
  }
}

C++: #include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
void field(void);
void move(void);
void clear(void);

  int w,h;
  char mass[103][103]={'\0'};
char now;

int main(){

  while(1){

    scanf("%d %d",&h,&w);

    if(w==h && h==0){
      break;
    }

    field();
    move();
    clear();

  }

  return 0;
}

void field(){

  int i,j;
  
  for(i=0;i<h;i++){
    scanf("%s",mass[i]);
  }

}

void move(){

  now=mass[0][0];
  int end=1,fw=0,fh=0,cnt=0;

  while(end){

    if(cnt==w*h){
      printf("LOOP\n");
      end=0;
    }

    else if(now=='.'){
      printf("%d %d\n",fw,fh);
      end=0;
    }

    else if(now=='>'){
      fw++;
    }

    else if(now=='v'){
      fh++;
    }

    else if(now=='^'){
      fh--;
    }

    else if(now=='<'){
      fw--;
    }

    now=mass[fh][fw];
    cnt++;

  }

}

void clear(){

  int i,j;

  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      mass[i][j]='\0';
    }
  }

}

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

int main() {
  int mapx, mapy;
  int x, y, tmp0 = 0, tmp1 = 0, tmp2 = 0;
  char map[150][150] = {0}, map0[150][150] = {0}, tmpc = 1;
  scanf("%d%d", &mapx, &mapy);
  while (mapx+mapy) {
    while (tmp0 < mapx) {
      scanf("%s", &map[tmp0]);
      tmp0++;
    }
    tmp0 = 0, tmp1 = 0, tmp2 = 0, tmpc = 1;
    x = 0, y = 0;
    while (tmpc && tmpc != 100) {
      map0[x][y]=1;
      if (map[x][y] == '>') y++;
      else if (map[x][y] == '<') y--;
      else if (map[x][y] == '^') x--;
      else if (map[x][y] == 'v') x++;
      else if (map[x][y] == '.') tmpc = 0;
      if (map0[x][y] && tmpc) tmpc = 100;
      tmp2++;
    }
    if (tmpc == 100) puts("LOOP");
    else printf("%d %d\n", (x+1), (y+1));
    scanf("%d%d", &mapx, &mapy);
  }
  return 0;
}