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>

void move(int, int);

char tiles[100][100];
bool mem[100][100];

int main()
{
  int H, W;
  while(true)
  {
    std::cin >> H >> W;
    if(!H && !W)
      break;

    for(int i = 0; i < H; i++)
      std::cin >> tiles[i];
    
    move(0, 0);
  }
  return 0;
}

void move(int x, int y)
{
  if(mem[y][x])
  {
    std::cout << "LOOP" << std::endl;
    return;
  }

  mem[y][x] = true;

  switch(tiles[y][x])
  {
    case '<':
      move(x - 1, y);
      return;
    case '>':
      move(x + 1, y);
      return;
    case '^':
      move(x, y - 1);
      return;
    case 'v':
      move(x, y + 1);
      return;
    case '.':
      std::cout << x << " " << y << std::endl;
      return;
  }
}

C++: #include <iostream>
#include <string>
using namespace std;
string tiles[100];
int main()
{
	int X,Y;
	while(1)
	{
		cin >> Y >> X ;
		if(X==0 && Y==0) break;
		for(int i=0;i<Y;i++) cin >> tiles[i] ;
		bool Loop=false; bool flag[100][100]={false};

		int curr_x=0; int curr_y=0; flag[0][0]=true;
		while(tiles[curr_y][curr_x]!='.')
		{
			if(tiles[curr_y][curr_x]=='>') curr_x++;
			else if(tiles[curr_y][curr_x]=='<') curr_x--;
			else if(tiles[curr_y][curr_x]=='^') curr_y--;
			else if(tiles[curr_y][curr_x]=='v') curr_y++;
			if(flag[curr_y][curr_x]==true) {Loop=true; break;}
			else flag[curr_y][curr_x]=true;
		}
		if(Loop==true) cout << "LOOP" << endl;
		else cout << curr_x << ' ' << curr_y << endl;
	}
}

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

using namespace std;

#define H_MAX 100
#define W_MAX 100

int H, W;

string f[H_MAX];      // field
bool p[H_MAX][W_MAX]; // have passed?

void go(int x, int y) {
    if (p[y][x]) {
        cout << "LOOP\n";
        return;
    }
    p[y][x] = true;
    switch (f[y][x]) {
        case '>':
            go(x+1, y);
            break;
        case '<':
            go(x-1, y);
            break;
        case '^':
            go(x, y-1);
            break;
        case 'v':
            go(x, y+1);
            break;
        default:
            cout << x << ' ' << y << endl;
            break;
    }
}

int main() {
    while (cin >> H >> W) {
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++) {
            cin >> f[i];
            for (int j = 0; j < W; j++) {
                p[i][j] = false;
            }
        }
        go(0, 0);
    }
    return 0;
}

C++: #include <stdio.h>
 
int main() {
 
  char map[101][101],a[102];
  int i,j,w,h,x,y,flag;
 
  while(1) {
    scanf("%d %d",&h,&w);
    if(w==0 && h ==0) break;
 
    for(i=0;i<h;i++) {
      scanf("%s",a);
      for(j=0;j<w;j++) {
    map[i][j] = a[j];
      }
 
    }
 
    flag = 0;
    x  = y = 0;
 
    while(1) {
      flag++;
      if(map[y][x] == '^')y--;
      else if(map[y][x] == '>')x++;
      else if(map[y][x] == 'v')y++;
      else if(map[y][x] == '<')x--;
      else if(map[y][x] == '.'){
    //  printf("break\n");
    break;
      }
       
      // printf("flag = %d\n",flag);
      if(flag >=25000) break;
    }
 
 
    if(flag >= 24000) printf("LOOP\n");
    else printf("%d %d\n",x,y);
 
  }
 
  return 0;
 }

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

char field[101][101];
bool check[101][101];

void tile(int x,int y) {
  if(check[y][x]) {
    check[y][x] = false;
  }
  else {
    cout << "LOOP" << endl;
    return;
  }

  if(field[y][x] == '>') {
    tile(x+1,y);
  }
  else if(field[y][x] == '<') {
    tile(x-1,y);
  }
  else if(field[y][x] == '^') {
    tile(x,y-1);
  }
  else if(field[y][x] == 'v') {
    tile(x,y+1);
  }
  else if(field[y][x] == '.') {
    cout << x << " " << y << endl;
    return;
  }
}

int main() {
  int W,H;
  string str;
  while(cin >> W >> H) {
    if(W==0 && H==0) break;
    getline(cin,str);//kill \n
    for(int i=0;i<W;i++) {
      getline(cin,str);
      for(int j=0;j<H;j++) {
        field[i][j] = *str.substr(j,1).c_str();
        check[i][j] = true;
      }
    }
    tile(0,0);
  }
}

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

char tile[150][150];
bool flag[150][150];

int solve(int x,int y){
	if(flag[x][y]) return -1;
	int ans;
	
	flag[x][y]=true;
	switch(tile[x][y]){
	case '>':
		ans=solve(x+1,y);
		break;
	case '<':
		ans=solve(x-1,y);
		break;
	case 'v':
		ans=solve(x,y+1);
		break;
	case '^':
		ans=solve(x,y-1);
		break;
	case '.':
		ans=x*1000+y;
		break;
	default:
		break;
	}
	return ans;
}

int main(){
	int W,H,ans;

	while(1){
		cin>>H>>W;
		if(W==0&&H==0) break;
	
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				flag[j][i]=false;
			}
		}
		
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>tile[j][i];
			}
		}
		
		if((ans=solve(0,0))==-1) cout<<"LOOP"<<endl;
		else cout<<ans/1000<<" "<<ans%1000<<endl;
	}
	
	return 0;
}

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

int main(void) {
  char G[102][102];
  bool visited[102][102];
  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>
using namespace std;

char field[100][100];

void search(int y,int x)
{
	if(field[y][x] == '.')
		cout << x << " " << y << endl;
	else if(field[y][x] == '0')
		cout << "LOOP" << endl;
	else{
		if(field[y][x] == '>'){
			field[y][x] = '0';
			search(y,x+1);
		}
		else if(field[y][x] == '<'){
			field[y][x] = '0';
			search(y,x-1);
		}
		else if(field[y][x] == 'v'){
			field[y][x] = '0';
			search(y+1,x);
		}
		else if(field[y][x] == '^'){
			field[y][x] = '0';
			search(y-1,x);
		}
	}
}

int main()
{
	int w,h;
	while(cin >> w >> h){
		if(!w && !h)
			break;
		for(int i=0;i<w;i++){
			for(int j=0;j<h;j++){
				cin >> field[i][j];
			}
		}
		search(0,0);
	}
	return 0;
}

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

int main()
{
	vector< vector<char> > tile(101, vector<char>(101));
	int W, H, i, j;
	map<pair<int, int>, int> passed;
	while (cin>>H>>W, H||W) {
		for (j = 0; j < H; j++)
			for (i = 0; i < W; i++)
				cin>>tile[i][j];
		i = 0;
		j = 0;
		passed.clear();
		while (!passed[make_pair(i,j)]) {
			if (tile[i][j]=='.') {
				cout<<i<<" "<<j<<endl;
				break;
			}
			passed[make_pair(i,j)] = 1;
			if (tile[i][j]=='<') i--;
			else if (tile[i][j]=='>') i++;
			else if (tile[i][j]=='^') j--;
			else if (tile[i][j]=='v') j++;
		}
		if (passed[make_pair(i,j)]) cout<<"LOOP"<<endl;
	}
	return 0;
}