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 <stdio.h>
int main(){
   int height,width,count,limit,row,col;
   char table[100][101];
   while(true){
       scanf("%d %d",&height,&width);
       if(height == 0 && width == 0)break;
       for(int i = 0; i < height; i++){
           scanf("%s",table[i]);}
       count = 0;
       row = 0; col = 0;
       limit = height*width;
       while(table[row][col] != '.' && count < limit){
           switch(table[row][col]){
           case '>':col++;
                   count++;
                   break;
           case '<':col--;
                   count++;
                   break;
           case '^':row--;
                   count++;
                   break;
           case 'v':row++;
                    count++;
                    break;}}
       if(count >= limit){
           printf("LOOP\n");}
	   else{
           printf("%d %d\n",col,row);}}
    return 0;
}

C++: #include <cstdio>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main() 
{
    int h,w;
    while (scanf("%d%d",&h,&w)) {
        if (h==0&&w==0) break;
        vector<string> map;
        for (int i=0; i<h; i++) {
            string in;
            cin>>in;
            map.push_back(in);
        }
        vector<vector<int> > went;
        for (int i=0; i<h; i++) {
            vector<int> num(w,0);
            went.push_back(num);
        }
        int ni=0, nj=0;
        bool flag=false;
        while (map[ni][nj]!='.') {
            if (went[ni][nj]==1) {
                flag=true;
                break;
            }
            went[ni][nj]++;
            if (map[ni][nj]=='>') {
                nj++;
            }
            else if (map[ni][nj]=='<') {
                nj--;
            }
            else if (map[ni][nj]=='^') {
                ni--;
            }
            else if (map[ni][nj]=='v') {
                ni++;
            }
        }
        if (flag) printf("LOOP\n");
        else printf("%d %d\n",nj,ni);
    }
}

C++: #include <iostream>
#include <string>
#include <cstdio>
#define MAX_N 105

using namespace std;
int n,h,w;
int area[MAX_N][MAX_N];
string s[MAX_N];

void move(int h,int w){
	if(area[h][w]==1){
		cout << "LOOP" << endl;
		return;
	}
	area[h][w]=1;
	
	switch(s[h][w]){

		case'>':
		move(h,w+1);
		return;
		break;

		case'<':
		move(h,w-1);
		return;
		break;

		case'v':
		move(h+1,w);
		return;
		break;

		case'^':
		move(h-1,w);
		return;
		break;

		case'.':
		cout << w<< " "<<h<<endl;
		return;
		break;
	}
	return;
}

int main(){
	while(1){
		cin >> h >> w;
		if(h==0&&w==0)break;
		for(int i;i<h;i++){
			for(int j;j<w;j++){
				area[i][j]==0;
			}
		}
		for(int i=0;i<h;i++){
			cin >> s[i];
		}
		move(0,0);

	}
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)




int main(void){
	int w,h;
	bool visited[100][100];
	char map[100][100];
	while(cin >> w >> h,w|h){
		rep(j,h)
			rep(i,w)
				cin >> map[i][j],visited[i][j]=false;
		bool loop=false;
		int x=0,y=0;
		while(!visited[x][y]&&map[x][y]!='.'){
			visited[x][y]=true;
			if(map[x][y]=='>')
				x++;
			else if(map[x][y]=='<')
				x--;
			else if(map[x][y]=='v')
				y++;
			else if(map[x][y]=='^')
				y--;
		}
		if(map[x][y]!='.')
			loop=true;

		if(loop)
			cout << "LOOP" << endl;
		else 
			cout << x << " "<< y << endl;
	}
	return 0;
}

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

string map[110];
int j_map[110][110];
int* ans(int* x){
	if(j_map[x[0]][x[1]]==1){
		x[0]=x[1]=-1;
		return x;
	}else{
		j_map[x[0]][x[1]]=1;
		
		if(map[x[0]][x[1]]=='v'){
			x[0]++;
			return ans(x);
		}else if(map[x[0]][x[1]]=='<'){
			x[1]--;
			return ans(x);
		}else if(map[x[0]][x[1]]=='>'){
			x[1]++;
			return ans(x);
		}else if(map[x[0]][x[1]]=='^'){
			x[0]--;
			return ans(x);
		}else{
			return x;
		}
	}
}



int main(){
	int w,h;
	while(cin>>w,cin>>h,(w!=0)&&(h!=0)){
		for(int i=0;i<w;i++){
			cin>>map[i];
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				j_map[i][j]=0;
			}
		}
		
		int* x=(int *)malloc(sizeof(int)*2);
		x[0]=x[1]=0;
		x = ans(x);
		if(x[0]==-1){
			cout<<"LOOP"<<endl;
		}else{
			cout<<x[1]<<" "<<x[0]<<endl;
		}
	}
	
}

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

int main()
{
	int h,w;
	while(cin>>h>>w&&h)
	{
		string a[120];
		for(int i=0;i<h;i++)
		{
			cin>>a[i];
		}
		pair<int,int> p(0,0);
		map< pair<int,int>,int > m;
		m[p]=1;
		bool ok=true;
		while(ok)
		{
			char now=a[p.first][p.second];
			switch(now)
			{
			case '^':
				p.first--;
				break;
			case '>':
				p.second++;
				break;
			case 'v':
				p.first++;
				break;
			case '<':
				p.second--;
				break;
			case '.':
				cout<<p.second<<" "<<p.first<<endl;
				ok=false;
				break;
			}
			if(ok&&m.count(p))
			{
				cout<<"LOOP"<<endl;
				break;
			}
			m[p]=1;
		}
		
	}
	
}

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

#define REP(i, m, n) for(int i = m; i < static_cast<int>(n); ++i)
int main()
{
    int height, width;
    std::vector<std::string> tile = {">", "<", "^", "v", "."};
    
    while (std::cin >> height >> width) {
        if (height == 0 && width == 0) {
            break;
        }
        
        std::vector< std::vector<std::string> > table;
            
        REP(i, 0, height) {
        table.push_back( std::vector<std::string>() );
            
        REP(j, 0, width) {
            std::string data;
            std::cin >> std::setw(1) >> data;
            table[i].push_back(data);
        }
    }
            
        
        bool flag = true;

        while (flag){
            static int i = 0;
            static int j = 0;
            
            if (table[i][j] == tile[0]) {
                table[i][j] = ",";
                j++;
                continue;
            } else if (table[i][j] == tile[1]) {
                table[i][j] = ",";
                j--;
                continue;
            } else if (table[i][j] == tile[2]) {
                table[i][j] = ",";
                i--;
                continue;
            } else if (table[i][j] == tile[3]) {
                table[i][j] = ",";
                i++;
                continue;
            } else if (table[i][j] == ",") {
                flag = false;
                std::cout << "LOOP" << std::endl;
                i = j = 0;
            } else {
                flag = false;
                std::cout << i << " " << j << std::endl;
                i = j = 0;
            }
        }
    }
    
    return 0;
}