Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	// var w, h int
	for scanner.Scan() {
		// fmt.Scanf("%d %d", &w, &h)

		input := strings.Split(scanner.Text(), " ")
		w, _ := strconv.Atoi(input[0])
		h, _ := strconv.Atoi(input[1])

		if w == 0 && h == 0 {
			return
		}

		isArrive := make([][]bool, w)
		tiles := make([][]string, w)

		for i := 0; i < w; i++ {
			rowArrive := make([]bool, h)
			rowTiles := make([]string, h)
			scanner.Scan()
			row := scanner.Text()
			for j := 0; j < h; j++ {
				rowTiles[j] = string(row[j])
			}
			tiles[i] = rowTiles
			isArrive[i] = rowArrive
		}

		var i, j int
		isEnd := false
		for {
			if isArrive[i][j] == true {
				fmt.Println("LOOP")
				break
			}
			isArrive[i][j] = true

			switch tiles[i][j] {
			case ">":
				j++
			case "^":
				i--
			case "v":
				i++
			case "<":
				j--
			case ".":
				isEnd = true
			}

			if isEnd == true {
				fmt.Println(j, i)
				break
			}
		}
	}
}

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

int main(){
	int h, w, i, j;
	while(cin >> h >> w, h != 0 or w != 0){
		int root[h][w];
		char tile[h][w];
		for(i = 0; i < h; i++){
			for(j = 0; j < w; j++){
				root[i][j] = 0;
			}
		}
		for(i = 0; i < h; i++){
			for(j = 0; j < w; j++){
				cin >> tile[i][j];
			}
		}
		
		i = 0;
		j = 0;
		while(tile[i][j] != '.'){
			if(root[i][j] != 0){
				cout << "LOOP" << endl;
				break;
			}
			root[i][j]++;
			switch(tile[i][j]){
				case '>':
					j++;
					break;
				case '<':
					j--;
					break;
				case 'v':
					i++;
					break;
				case '^':
					i--;
					break;
			}
		}
		if(tile[i][j] == '.') cout << j << ' ' << i << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	int array1[10001], array2[10001], n, m, tmp, i, j;
	char w;
	
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0){
			break;
		}
		fill(array1, array1+10001, 0);
		fill(array2, array2+10001, 0);
		for(i = 0; i < n; i++){
			for(j = 0, tmp = i*m; j < m; j++){
				cin >> w;
				if(tmp < 0){
					break;
				}
				if(w == '>'){
					array1[tmp+j] = tmp + j + 1;
				} else if(w == 'v'){
					array1[tmp+j] = tmp + j + m;
				} else if(w == '<'){
					array1[tmp+j] = tmp + j -1;
				} else if(w == '^'){
					array1[tmp+j] = tmp + j - m;
				} else {
					array1[tmp+j] = -1;
				}
			}
			if(tmp < 0){
				break;
			}
		}
		if(tmp < 0){
			cout << "LOOP" << endl;
			continue;
		}
		
		tmp = array1[0];
		array2[0] = 1;
		while(1){
			if(array2[tmp] == 1){
				cout << "LOOP" << endl;
				break;
			} else if(array1[tmp] == -1){
				i = tmp % m;
				j = (int)(tmp / m);
				cout << i << " " << j << endl;
				break;
			}
			array2[tmp] = 1;
			tmp = array1[tmp];
		}
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(ll i=(a);i<ll(b);i++)
#define rep(i,b) loop(i,0,b)

int h,w;
char g[110][110];
int vis[110][110];
map<char,int> di = {
    {'>',0},
    {'<',0},
    {'v',1},
    {'^',-1}
}, dj = {
    {'>',1},
    {'<',-1},
    {'v',0},
    {'^',0}
};

pair<int,int> solve(int ci, int cj){
    if(vis[ci][cj]) return make_pair(-1,-1);
    vis[ci][cj] = true;
    if(g[ci][cj] == '.') return make_pair(ci,cj);
    int c = g[ci][cj];
    return solve(ci+di[c], cj+dj[c]);
}

int main(){
    while(scanf("%d%d",&h,&w), w != 0){
        rep(i,h) scanf("%s",g[i]);
        rep(i,h)rep(j,w) vis[i][j] = false;
        int i,j;
        tie(i,j) = solve(0,0);
        if(i==-1) puts("LOOP");
        else printf("%d %d\n",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;
		}
	}
	
}