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[200][200];
  bool visited[200][200];
  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.h>
using namespace std;

int m,n,w,h;
char b[102][102];
bool v[102][102];

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

int main(){
    while(cin>>h>>w,w||h){
        for(int i=0;i<h;i++)
            cin>>b[i];
        memset(v,0,sizeof(v));
        dfs(0,0);
    }
}

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

int main(){
	int w,h;
	string m[110];
	bool f[110][110], flag;
	
	while( cin >> h >> w , w, h ){
		flag = false;
		for(int y=0 ; y<h ; y++){
			m[y].clear();
			for(int x=0 ; x<w ; x++){
				f[y][x] = false;
			}
		}
		for(int y=0 ; y<h ; y++){
			cin >> m[y];
		}
		int x=0, y=0;
		while(1){
			if( m[y][x]=='>' ) x++;
			if( m[y][x]=='<' ) x--;
			if( m[y][x]=='v' ) y++;
			if( m[y][x]=='^' ) y--;
			
			if( m[y][x]=='.' || f[y][x] ){
				( f[y][x] )? flag = true : ;
				break;
			}
			f[y][x] = true;
		}
		(flag)? (cout << "LOOP" << endl) : (cout << x << " " << y << endl); 
	}
	return 0;
}

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

struct point{
	char c;
	int count;
};

void move(point area[100][100], int &i, int &j){
	area[i][j].count = 0;
	if(area[i][j].c == '>'){
		j++;
	}else if(area[i][j].c == '<'){
		j--;
	}else if(area[i][j].c == 'v'){
		i++;
	}else if(area[i][j].c == '^'){
		i--;
	}
}

int main(){
	int h, w;
	string s;
	point area[100][100];
	while(cin >> h >> w){
		if(h == 0 && w == 0) break;
		for(int i = 0; i < h; i++){
			cin >> s;
			for(int j = 0; j < s.size(); j++){
				area[i][j].c = s[j];
				area[i][j].count = 1;
			}
		}
		int i = 0, j = 0;
		while((area[i][j].c != '.') && (area[i][j].count = 0)){
			move(area, i, j);
		}
		if(area[i][j].c == '.') cout << j << " " << i << endl;
		else cout << "LOOP" << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	int w, h;
	char room[100][100];
	vector< pair<int, int> > visited;
	if(cin >> h >> w, h || w){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> room[i][j];
			}
		}
		visited.push_back(pair<int, int>(0, 0));
		int flag = 1;
		while (flag){
			pair<int, int> tmp;
			switch (room[visited.back().first][visited.back().second])
			{
			case '>':
				tmp.first = visited.back().first;
				tmp.second = visited.back().second + 1;
				visited.push_back(tmp);
				break;
			case '<':
				tmp.first = visited.back().first;
				tmp.second = visited.back().second - 1;
				visited.push_back(tmp);
				break;
			case '^':
				tmp.first = visited.back().first - 1;
				tmp.second = visited.back().second;
				visited.push_back(tmp);
				break;
			case 'v':
				tmp.first = visited.back().first + 1;
				tmp.second = visited.back().second;
				visited.push_back(tmp);
				break;
			case '.':
				cout << visited.back().second << ' ' << visited.back().first << endl;
				flag = 0;
				break;
			}
			for (int i = visited.size() - 2; i >= 0; i--){
				if (visited[i] == tmp){
					cout << "LOOP" << endl;
					flag = 0;
					break;
				}
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
//#include <map>
#include <vector>

using namespace std;



int H, W;
string map[101];


void saiki(int h, int w)
{
	
	//cout << "h = " << h << " : w = " << w << endl;
	
	if (map[h][w] == '.')
	{
		cout << w << " " << h << endl;
	} else if (map[h][w] == '1') {
		cout << "LOOP" << endl;
	} else if (map[h][w] == '>') {
		map[h][w] = '1';
		saiki(h, w + 1);
	} else if (map[h][w] == 'v') {
		map[h][w] = '1';
		saiki(h + 1, w);
	} else if (map[h][w] == '<') {
		map[h][w] = '1';
		saiki(h, w - 1);
	} else if (map[h][w] == '^') {
		map[h][w] = '1';
		saiki(h - 1, w);
	}
}


int main()
{
	while (cin >> H >> W)
	{
		if (H == 0 && W == 0) break;
		
		for (int i=0; i<H; i++)
		{
			cin >> map[i];
		}
		/*
		for (int i=0; i<H; i++)
		{
			cout << map[i] << endl;
		}
		*/
		saiki(0, 0);
	}
	
	return 0;
}

C++: #include <iostream>

constexpr int dx[]={0,-1,0,1,0},dy[]={0,0,-1,0,1};

int h,w;

int board[100][100];

bool used[100][100];

void dfs(int x,int y) {
	used[y][x]=true;

	if(!board[y][x]){
		std::cout<<x<<' '<<y<<std::endl;
		return;
	}

	int nx=dx[board[y][x]]+x,ny=dy[board[y][x]]+y;

	if(used[ny][nx]){
		std::cout<<"LOOP"<<std::endl;
		return;
	}

	dfs(nx,ny);

	used[y][x]=false;
}

int main() {
	while(1){
		std::cin>>h>>w;
		if(h+w==0)
			break;
		char ch;
		for(int i=0;i<h;++i){
			for(int j=0;j<w;++j){
				std::cin>>ch;
				if(ch=='<')
					board[i][j]=1;
				else if(ch=='^')
					board[i][j]=2;
				else if(ch=='>')
					board[i][j]=3;
				else if(ch=='v')
					board[i][j]=4;
			}
		}
		dfs(0,0);
	}
	return 0;
}