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 <cstdio>
using namespace std;

int main(void) {
  char G[100][100];
  bool visited[100][100];
  int W, H;
  string str;
  
  while(cin >> W >> H) {
    if(W==0 && H==0) break;
    for(int i=0; i<H; i++) {
      cin >> str;
      for(int j=0; j<W; j++) {
	G[i][j] = str[j];
	visited[i][j] = false;
      }
    }
    
    
    int x=0, y=0;
    while(1) {
      if(visited[y][x]) { cout << "LOOP" << endl; break; }
      
      visited[y][x] = true;
      if(G[y][x] == '>') x++;
      else if(G[y][x] == 'v') y++;
      else if(G[y][x] == '^') y--;
      else if(G[y][x] == '<') x--;
      else if(G[y][x] == '.') { cout << x << " " << y << endl; break; }

    }

  }
  
  return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	int H,W;
	char c,tail[101][101];
	while(cin>>H>>W&&H!=0&&W!=0){
		bool z[101][101]={0};
		int x=0,y=0,cnt=0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>tail[i][j];
			}
		}
		for(int i=0;i<H*W;i++){
			if(tail[x][y]=='>'){
				if(z[x][y]==1)break;
				z[x][y]=1;
				y+=1;
			}else if(tail[x][y]=='<'){
				if(z[x][y]==1)break;
				z[x][y]=1;
				y-=1;
			}else if(tail[x][y]=='^'){
				if(z[x][y]==1)break;
				z[x][y]=1;
				x-=1;
			}else if(tail[x][y]=='v'){
				if(z[x][y]==1)break;
				z[x][y]=1;
				x+=1;
			}else{
				cnt=1;
				cout<<y<<" "<<x<<endl;
				break;
			}
		}
		if(cnt==0)cout<<"LOOP"<<endl;
	}
	return 0;
}

C++: 

#include<iostream>
#include<vector>
#include<string>

using namespace std;

char f[101][101];
int judge[101][101];
int ex, ey;

void move(int i, int j)
{
	//printf("%3d:%3d\n", i, j);
	if(judge[i][j] == 1)
	{
		ex = -1; ey = -1;
		return;
	}
	else if(f[i][j] == '.')
	{
		ex = j; ey = i;
		return;
	}

	judge[i][j] = 1;

	if(f[i][j] == '>')
	{
		move(i, j+1);
	}
	else if(f[i][j] == '<')
	{
		move(i, j-1);
	}
	else if(f[i][j] == '^')
	{
		move(i-1, j);
	}
	else if(f[i][j] == 'v')
	{
		move(i+1, j);
	}

}

int main()
{
	int w, h;
	while(cin >> h >> w)
	{
		if(h == 0 && w == 0) break;
		for(int i = 0; i < h; i++)
		{
			cin >> f[i];
		}
		/*
		   for(int i = 0; i < h; i++)
		   {
		   for(int j = 0; j < w; j++)
		   {
		   cout << f[i][j];
		   }
		   cout << endl;
		   }
		   */
		//cout << "Run" << endl;
		move(0, 0);
		//cout << "Finish" << endl;

		if(ex == -1 && ey == -1)
		{
			cout << "LOOP" << endl;
		}
		else
		{
			cout << ex << ' ' << ey << endl;
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

bool visited[120][120];
char field[120][120];

int main(){
    int h,w,i;

    while( cin >> h >> w, h|w ){
        // init
        memset(visited, false, sizeof(visited));

        // input
        rep(i,h) cin >> field[i];

        int x = 0, y = 0;
        visited[y][x] = true;
        while( true ){
            switch( field[y][x] ){
            case '>': x++; break;
            case '<': x--; break;
            case '^': y--; break;
            case 'v': y++; break;
            default: break;
            }
            if( field[y][x] == '.' ){
                printf("%d %d\n",x,y);
                break;
            }
            if( visited[y][x] ){
                puts("LOOP");
                break;
            }
            visited[y][x] = true;
        }
    }

    return 0;
}

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

int main(){
	string map[110];
	int w, h;
	bool f[110][110], flag;

	while( cin >> w >> h , w , h ){
		for(int i=0 ; i<110 ; i++){
			map[i].clear();
		}
		for(int y=0 ; y<110 ; y++){
			for(int x=0 ; x<110 ; x++){
				f[y][x] = false;
			}
		}
		flag = false;

		for(int i=0 ; i<h ; i++){
			cin >> map[i];
		}
		int x=0,y=0;
		while( map[y][x] != '.' ){
			f[y][x] = true;
			if( map[y][x] == '>' ){
				x++;
			}else if( map[y][x] == '<' ){
				x--;
			}else if( map[y][x] == 'v' ){
				y++;
			}else if( map[y][x] == '^' ){
				y--;
			}

			if(f[y][x]){
				flag = true;
				break;
			}
		}
		(flag)? cout << "LOOP" << endl : cout << x << y << endl;
	}

	return 0;
}

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

using namespace std;

int main(){
	char map[100][100];
	int w, h, x = 0, y = 0, lx, ly, c;

	while (1){
		c = 0;

		cin >> h >> w;

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

		//input
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> map[i][j];
				cout << map[i][j];
			}
			cout << endl;
		}

		//detect
		while(1){
			c++;
			
			if (c > w*h){
				lx = -1;
				ly = -1;
				break;
			}

			switch (map[y][x]){
			case '>':x++; break;
			case '<':x--; break;
			case '^':y--; break;
			case 'v':y++; break;
			}

			if (map[y][x] == '.'){
				lx = x; ly = y;
				break;
			}
		}

		if (lx == -1 && ly == -1){
			cout << "LOOP" << endl;
		}
		else{
			cout << lx << ' ' << ly << endl;
		}

		x = y = 0;
	}

	return 0;
}

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

int w,h;
char t[102][102];

int dx[128];
int dy[128];

int main(void){
	dx['>'] = 1;
	dx['<'] = -1;
	dy['v'] = 1;
	dy['^'] = -1;

	while(cin>>h>>w && (h||w)){
		for(int i=0;i<h;i++){
			cin>>t[i];
		}

		int x = 0, y = 0;
		while(t[y][x] != '?' && t[y][x] != '.'){
			int nx = x + dx[t[y][x]];
			int ny = y + dy[t[y][x]];
			t[y][x] = '?';
			x = nx;
			y = ny;
		}
		if(t[y][x] == '?'){
			cout<<"LOOP\n";
		}
		else{
			cout<<x<<" "<<y<<endl;
		}
	}

	return 0;
}

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

int main(){
  int w,h;
  char map[100][100];
  int x,y;

  while(1){
    cin >> h >> w;
    if(!h && !w)break;

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> map[i][j];
      }
    }

    x = 0;
    y = 0;
    int count = 0;
    int flag = 0;
    while(1){
      count++;
      if(map[y][x] == '^')y--;
      if(map[y][x] == '>')x++;
      if(map[y][x] == 'v')y++;
      if(map[y][x] == '<')x--;
      if(map[y][x] == '.')break;
      if(count>h*w){
	flag = 1;
	break;
      }
    }
    if(flag)cout << "LOOP" << endl;
    else cout << x << " " << y << endl;
  }
}