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 x,y;
    while(cin>>x>>y,x||y){
        string map[x];
        for(int i=0;i<x;i++){
            cin>>map[i];
        }
        int X=0,Y=0;
        bool end=false;
        int loopCount=1;
        while(true){
            switch(map[Y][X]){
                case '^' :
                    Y--;
                    break;
                case '>' :
                    X++;
                    break;
                case 'v' :
                    Y++;
                    break;
                case '<' :
                    X--;
                    break;
                case '.' :
                    end=true;
                    break;
            }
            if(end){
                cout<<X<<' '<<Y<<endl;
                break;
            }
            if(loopCount>x*y){
                cout<<"LOOP"<<endl;
                break;
            }
            loopCount++;
        }
    }
}

C++: #include <iostream>
#include <algorithm>
#define MH 100
#define MW 100
using namespace std;
char f[MH][MW];
bool u[MH][MW];

void move(int x, int y) {
	if (u[y][x] == true) cout << "LOOP" << endl;
	else {
		u[y][x] = true;
		if (f[y][x] == '.') cout << x << " " << y << endl;
		else {
			if (f[y][x] == '<') move(x - 1, y);
			if (f[y][x] == '^') move(x, y - 1);
			if (f[y][x] == '>') move(x + 1, y);
			if (f[y][x] == 'v') move(x, y + 1);
		}
	}
	return;
}

int main() {
	int h, w;

	while (cin >> h >> w, !(h == 0 && w == 0)) {
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				cin >> f[i][j];
			}
		}
		fill(u[0], u[MH], false);
		move(0, 0);
	}
	return 0;
}

C++: #include <stdio.h>
#define North 0
#define East 1
#define West 2
#define South 3
#define No 4

int src[5][2]={{-1,0},{0,1},{0,-1},{1,0},{0,0}};

class Pair{
public:
	Pair(){x=y=0;}
	void move(int t){
		x+=src[t][0];
		y+=src[t][1];
	}
	int x,y;
};

int main(){
	while(1){
		int h,w;
		bool stop=false;
		Pair pos;
		char c[101][101];
		scanf("%d%d",&h,&w);
		if(!h&&!w) break;
		for(int i=0;i<h;i++) scanf("%s",c[i]);
		while(!stop){
			Pair tmp=pos;
			switch(c[pos.x][pos.y]){
			case '^':
				pos.move(North);
				break;
			case '>':
				pos.move(East);
				break;
			case '<':
				pos.move(West);
				break;
			case 'v':
				pos.move(South);
				break;
			case '.':
				stop=true;
				printf("%d %d\n",pos.y,pos.x);
				break;
			case 0:
				stop=true;
				printf("LOOP\n");
			}
			c[tmp.x][tmp.y]=0;
		}
	}
	return 0;
}

C++: #include<iosteram>
#include<string>

using namespace std;

int main(void){
	int w,h;
	while(cin>>>h>>w,h){
		string f[h];
		for(int i=0,i<h;i++){
			cin>>f[i];
		}	
		int x,y;
		x=y=0;
		bool used[h][w];
		memset(used,0,sizeof(used));
		while(true){
			if(used[y][x]){
				cout<<"LOOP"<<endl;
				break;
			}
			if(f[y][x]=='.'){
				cout<<x<<" "<<y<<endl;
				break;
			}
			used[y][x]=true;
		}
	
		switch(f[y][x]){
			case '>': x+=1; break;
			case '<': x-=1; break;
			case '^': y-=1; break;
			case 'v': y+=1; break;
		}
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int h,w;
    while(cin >> h >> w){
        if(!h && !w) break;

        vector<string> map(h);
        rep(i,h) cin >> map[i];

        int i = 0, j = 0;
        while(1){
            if(map[i][j] == 'x'){
                cout << "LOOP" << endl;
                break;
            }
            if(map[i][j] == '.'){
                cout << j << " " << i << endl;
                break;
            }
            if(map[i][j] == '>'){
                map[i][j] = 'x';
                j++;
                continue;
            }
            if(map[i][j] == '<'){
                map[i][j] = 'x';
                j--;
                continue;
            }
            if(map[i][j] == '^'){
                map[i][j] = 'x';
                i--;
                continue;
            }
            if(map[i][j] == 'v'){
                map[i][j] = 'x';
                i++;
                continue;
            }
        }
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
#define MAX (256)

char field[MAX][MAX];

int main(){
	int w, h;
	while(cin >> w >> h, w || h){
		for(int i=0; i < w; i++){
			for(int j=0; j < h; j++){
				cin >> field[i][j];
			}
		}
		int x=0, y=0;
		while(1){
			switch(field[x][y]){
				case '>':
					field[x][y] = '#';
					y++;
					break;
				case 'v':
					field[x][y] = '#';
					x++;
					break;
				case '<':
					field[x][y] = '#';
					y--;
					break;
				case '^':
					field[x][y] = '#';
					x--;
					break;
				case '.':
					field[x][y] = '%';
					cout << y << ' ' << x << endl;
					break;
				case '#':
					field[x][y] = '%';
					cout << "LOOP" << endl;
					break;
			}
			if(field[x][y] == '%') break;
		}
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int h,w;

char M[101][101];

pair<int,int> f(int y,int x){
  pair<int,int> p;
  if(M[y][x]=='.'){
    p=mp(y,x);
    return p;
  }
  if(M[y][x]=='#'){
    p=mp(-1,-1);
    return p;
  }
  if(M[y][x]=='>'){
    M[y][x]='#';
    f(y,x+1);
  }else if(M[y][x]=='^'){
    M[y][x]='#';
    f(y-1,x);
  }else if(M[y][x]=='<'){
    M[y][x]='#';
    f(y,x-1);
  }else if(M[y][x]=='v'){
    M[y][x]='#';
    f(y+1,x);
  }
}

signed main(){
  while(cin>>h>>w,h){
    rep(i,h)rep(j,w)cin>>M[i][j];
    pair<int,int> P=f(0,0);
    if(P.fir==-1&&P.sec==-1){
      cout<<"LOOP"<<endl;
    }else{
      cout<<P.sec<<' '<<P.fir<<endl;
    }
  }
  return 0;
}