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<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;
		}
	}
}

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;
}