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 <stdio.h>
#include <stdlib.h>

typedef struct {
	int x;
	int y;
} posn;

posn* next(posn *now, char bord[128][128], int W, int H) {
	posn* ans;

	ans = (posn*)malloc(sizeof(posn));

	switch(bord[now->y][now->x]) {
		case '>' : if(now->x < W - 1)
					   ans->x = now->x + 1;
				   else
					   ans->x = now->x;
				   break;

		case '<' : if(now->x > 0)
					   ans->x = now->x - 1;
				   else
					   ans->x = now->x;
				   break;

		case 'v' : if(now->y < H - 1)
					   ans->y = now->y + 1;
				   else
					   ans->y = now->y;
				   break;

		case '^' : if(now->y > 0)
					   ans->y = now->y - 1;
				   else
					   ans->y = now->y;
				   break;

		case '.' : ans->x = now->x;
				   ans->y = now->y;
				   break;
	}

	return ans;
}

int main() {
	int W , H;
	char bord[128][128];
	int count = 0;
	posn now;
	posn *temp;

	int i, j;

	while(1) {
		scanf("%d %d", &H, &W);
		if(W == 0 && H == 0)
			break;

		for(i = 0; i < H; i++)
			scanf("%s", bord[i]);

		now.x = 0; now.y = 0;

		count = 0;
		while(count < W * H) {
			temp = next(&now, bord, W, H);
		
			if(temp->x == now.x && temp->y == now.y)
				break;
			
			else {
				now.x = temp->x;
				now.y = temp->y;
			}

			count++;
			free(temp);
		}

		if(count == W * H)
			printf("LOOP\n");
		else
			printf("%d %d\n", now.x, now.y);

	}
	
	return 0;
}

C++: #include <stdio.h>
int main() {int N,M,i,j;char RB[105][105];while (scanf("%d %d",&N,&M)!=EOF && N && M) {for (i=0;i<N;scanf("%s",&RB[i++]));i=0,j=0;while (RB[i][j]!='?' && RB[i][j]!='.') {if (RB[i][j]=='>') RB[i][j++]='?'; else if (RB[i][j]=='<') RB[i][j--]='?'; else if (RB[i][j]=='^') RB[i--][j]='?'; else RB[i++][j]='?';} if (RB[i][j]=='.') printf("%d %d\n",j,i); else printf("LOOP\n");} return 0;}

C++: #include<iostream>
using namespace std;
const int MAX = 101;
char m[MAX+1][MAX+1];

int main(){
	int h,w;
	while(cin >> h >> w){
		bool visited[MAX+1][MAX+1];
		if(h==0 && w==0) break;

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

C++: #include<cstdio>
#include<cstring>


int main()
{
	int w,k,hyou[100][100],i,j,checki[100],check[100],l=0;
	memset(check,0,100*sizeof(int));
	char a;
	while(1)
	{
		scanf("%d%d",&w,&k);
		if(w==0)
			break;
		scanf("%c",&a);
		for(i=0;i<w;i++)
		{
			for(j=0;j<=k;j++)
			{
				scanf("%c",&a);
				if(a=='>')
					hyou[i][j]=1;
				else	if(a=='<')
					hyou[i][j]=2;
				else if(a=='v')
					hyou[i][j]=3;
				else if(a=='^')
					hyou[i][j]=4;
				else if(a=='.')
					hyou[i][j]=0;
				else 
					hyou[i][j]=6;
			}
			
			
		}
		i=0;
		j=0;
		while(hyou[i][j]!=5&&hyou[i][j]!=0)
		{
			switch(hyou[i][j])
			{
			case 1:
				hyou[i][j]=5;
				j++;
				break;
			case 2:
				hyou[i][j]=5;
				j--;
				break;
			case 3:
				hyou[i][j]=5;
				i++;
				break;
			case 4:
				hyou[i][j]=5;
				i--;
				break;
			case 0:
				check[l]=i*10+j;
				break;
			case 5:
				check[l]=0;
				break;
			}
		}
		if(hyou[i][j]==0)
			check[l]=i;
			checki[l]=j;
		l++;
	}
	for(i=0;i<l;i++)
	{
		if(check[i]==0)
			printf("LOOP\n");
		else
			printf("%d %d\n",checki[i],check[i]);
	}
	return 0;
}

C++: #include<stdio.h>
main(){
  int i,j;
  int H,W;
  int count=0;
  char tairu[1000][1000];
  int sub[1000][1000]={0};
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0) break;
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	scanf(" %c",&tairu[i][j]);
      }
    }
    i=0;
    j=0;
    while(count!=1){
      if(tairu[i][j]=='.') break;
      if(tairu[i][j]=='>'){ 
	j++;
	if(sub[i][j]==1){
	  count=1;
	}
	sub[i][j]=1;
      }
      if(tairu[i][j]=='v'){
	i++;
	if(sub[i][j]==1){
	  count=1;
	}
	sub[i][j]=1;
      }
      if(tairu[i][j]=='<'){ 
	j--;
	if(sub[i][j]==1){
	  count=1;
	}
	sub[i][j]=1;
      }
      if(tairu[i][j]=='^'){
	i--;
	if(sub[i][j]==1){
	  count=1;
	}
	sub[i][j]=1;
      }
    }
    if(count==1) printf("LOOP\n");
    else{
      printf("%d %d\n",j,i);
    }
  }
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main() {
  while(1){
    int h,w;
    cin>>h>>w;
    if(!h)break;
    vector<string> t(h);
    REP(i,h)cin>>t[i];
    string s=">v<^.";
    int di[]={0,1,0,-1,0};
    int dj[]={1,0,-1,0,0};
    set<pair<int,int>> st;
    int i=0,j=0;
    bool loop = false;
    while(t[i][j] != '.') {
      if (st.find(make_pair(i,j))!=end(st)) {
        loop=true;
        break;
      }
      st.insert(make_pair(i,j));
      int id=find(begin(s),end(s),t[i][j])-begin(s);
      tie(i,j)=make_pair(i+di[id],j+dj[id]);
    }
    if(loop)
      cout << "LOOP" << endl;
    else
      cout << j << ' '<<i<<endl;
  }
  return 0;
}

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

int main(){
  int n ,m;
  while( true ){
    cin >> n >> m;
    if( n == 0 && m == 0 ){
      break;
    }
    string tail[n];
    int mass[n][m];
    for( int i=0 ; i<n ; i++ ){ 
      for( int j=0 ; j<m ; j++ ){
	mass[i][j] = 0;
      }
    }

    for( int i=0 ; i<n ; i++ ){
      cin >> tail[i];
    }
    
    n = 0; m = 0;
    
    while( true ){
      if( mass[n][m] == 1 ){
	cout << "LOOP" << endl;
	break;
      }
      else if( tail[n][m] == '>' ){
	mass[n][m] = 1;
	m++;
      }
      else if( tail[n][m] == '<' ){
     	mass[n][m] = 1;
	m--;
      }
      else if( tail[n][m] == '^' ){
	mass[n][m] = 1;
	n--;
      }
      else if( tail[n][m] == 'v' ){
       	mass[n][m] = 1;
	n++;
      }
      else if( tail[n][m] == '.' ){
	cout << m << ' ' << n << endl;
	break;
      }
    }
  }
}

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

int main(void){
	int w,h;
	while(cin>>h>>w,h){
		string f[h];
		for(int i=0;i<h;i++){
			cin>>f[i];
		}	
		int x,y;
		x=y=0;
		bool used[h][w];
		memset(used,0,sizeof(used));
		while(true){
			if(used[y][x]){
				cout<<"LOOP"<<endl;
				break;
			}
			if(f[y][x]=='.'){
				cout<<x<<" "<<y<<endl;
				break;
			}
			used[y][x]=true;
		}
	
		switch(f[y][x]){
			case '>': x+=1; break;
			case '<': x-=1; break;
			case '^': y-=1; break;
			case 'v': y+=1; break;
		}
	}
}