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>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int w,h;
	while(cin>>h>>w,h) 
	{
		string f[h];
		for(int i = 0; i < h; ++i)
		{
			cin>>f[i];
		}

		bool used[h][w];
		memset(used,0,sizeof(used));

		int x=0,y=0;
		while(1) 
		{
			if(used[y][x])
			{
				cout<<"LOOP"<<endl;
				break;
			}
			if(f[y][x]=='.')
			{
				cout<<x<<" "<<y<<endl;
				break;
			}
			used[y][x]=true;

			if(f[y][x]=='>') x+=1;
			if(f[y][x]=='<') x-=1;
			if(f[y][x]=='^') y-=1;
			if(f[y][x]=='v') y+=1;
		}
	}
  return 0;
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

typedef map<int, pair<int, long long> > mipill;

int main()
{
	int w, h;
	while(scanf("%d%d", &h, &w), w){
		vector<vector<bool> > memo(h, vector<bool>(w, false));
		vector<string> field(h);
		rep(i, h){
			char str[128];
			scanf("%s", str);
			field[i] = string(str);
		}

		int y = 0, x = 0;
		while(field[y][x] != '.' && !memo[y][x]){
			memo[y][x] = true;
			if(field[y][x] == '>')
				++x;
			else if(field[y][x] == 'v')
				++y;
			else if(field[y][x] == '^')
				--y;
			else
				--x;
		}

		if(field[y][x] == '.')
			printf("%d %d\n", x, y);
		else
			puts("LOOP");
	}

	return 0;
}

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

int main(){
	char ss[2][110][111];
	int w,h,i,x,y,loop;
	
	while(~scanf("%d%d",&w,&h)){
		if(w==0 && h==0)break;
		
		memset(ss,0,sizeof(ss));
		
		for(i=0;i<w;i++){
			scanf(" %s ",ss[0][i]);
		}
		
		x=0;
		y=0;
		loop=0;
		ss[1][y][x]=1;
		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 "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

string fie[30]={};


int main(){
    int h,w;
    while(cin>>h>>w){
        if(w==0 && h==0)break;

        rep(i,h){
            cin>>fie[i];
        }

        int y=0,x=0;

        int c=0;
        while(c<1000000){
            c++;
            char ch = fie[y][x];
            if(ch=='>'){
                x++;
            }else if(ch=='<'){
                x--;
            }else if(ch=='^'){
                y--;
            }else if(ch=='v'){
                y++;
            }else break;
        }
        if(c==1000000)cout<<"LOOP"<<endl;
        else cout<<x<<" "<<y<<endl;
    }
}

C++: #include<iostream>
using namespace std;
int main(void)
{
  int h,w;
  while(true)
    {
      cin>>h>>w;
      if(h==0 && w==0)break;
      char str[h][w];
      for(int i=0;i<h;i++)
	{
	  for(int j=0;j<w;j++)
	    {
	      cin>>str[i][j];
	    }
	}
      int i=0,j=0;
      int looper[h][w];
      while(true)
	{
	  if(str[i][j]=='>')
	    {
	      
	      j++;
	    }
	  else if(str[i][j]=='<')
	    {
	      j--;
	      
	    }
	  else if(str[i][j]=='v')
	    {
	      i++;
	    }
	  else 
	    {
	      i--;
	    }
	  looper[i][j]++;
	  if(str[i][j]=='.')
	    {
	      cout<<j<<" "<<i<<endl;
	      break;
	    }
	  else if(looper[i][j]==1)
	    {
	      cout<<"LOOP"<<endl;
	      break;
	    }
	  
	  
	}
 
    }
        return 0;
}

C++: #include <iostream>

int main(int argc, char **argv)
{
	int h, w;
	int x = 0, y = 0;
	char tiles[100][100];
	bool throughed[100][100] = {};
	bool loop = false;
	bool end = false;
	while(std::cin >> h >> w, h+w != 0){
		x = 0;
		y = 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				throughed[j][i] = false;
			}
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				std::cin >> tiles[j][i];
			}
		}
		while(true){
			if(throughed[x][y]){
				loop = true;
				break;
			}
			throughed[x][y] = true;
			switch(tiles[x][y]){
				case '.':
					end = true;
					break;
				case '^':
					y--;
					break;
				case 'v':
					y++;
					break;
				case '<':
					x--;
					break;
				case '>':
					x++;
					break;
			}
			if(end){
				break;
			}
		}
		if(loop){
			std::cout << "LOOP" << std::endl;
		}else{
			std::cout << x << " " << y << std::endl;
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int H,W;
int x,y,flg;
string str;
int t[200][200];
void compute(){
  int a;
  if(t[y][x]==-1)return;
  if(t[y][x]==-2)flg=1;
  else {
    a=t[y][x];
    t[y][x]=-2;
    y=y+dy[a];
    x=x+dx[a];
    compute();
  }
}
int main(){
  while(cin>>H>>W){
    if(H==0&&W==0)break;
    for(int i=0;i<H;i++){
      cin>>str;
      for(int j=0;j<W;j++){
	if(str[j]=='^')t[i][j]=0;
	else if(str[j]=='>')t[i][j]=1;
	else if(str[j]=='v')t[i][j]=2;
	else if(str[j]=='<')t[i][j]=3;
	else t[i][j]=-1;
      }
    }
    x=y=flg=0;
    compute();
    if(flg)cout<<"LOOP"<<endl;
    else cout<<x<<' '<<y<<endl;
  }
  return 0;
}

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

int h, w;
char tile[100][100];
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
std::string arrows = "^>v<";

int main()
{
	while( std::cin >> h >> w, h | w )
	{
		for( int i = 0; i != h; ++i )
			for( int j = 0; j != w; ++j )
				std::cin >> tile[i][j];

		int x = 0, y = 0;
		while( true )
		{
			if( tile[y][x] == '-' )
			{
				std::cout << "LOOP" << std::endl;
				break;
			}
			else if( tile[y][x] != '.' )
			{
				int i = arrows.find( tile[y][x] );
				tile[y][x] = '-';
				x += dx[i]; y += dy[i];
			}
			else
			{
				std::cout << x << " " << y << std::endl;
				break;
			}
		}
	}

	return 0;
}