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>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int h,w;cin>>h>>w,h|w;){
		vs field(h);
		rep(i,h)
			cin>>field[i];
		vvi flg(h,vi(w));
		for(int x=0,y=0;;){
			if(field[y][x]=='.'){
				cout<<x<<" "<<y<<endl;
				break;
			}
			if(flg[y][x]){
				cout<<"LOOP"<<endl;
				break;
			}
			flg[y][x]=true;
			switch(field[y][x]){
				case '^': y--; break;
				case 'v': y++; break;
				case '<': x--; break;
				case '>': x++; break;
			}
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	string date[111];
	int a, b;
	int x, y,loop;
	int date2[111][111];
	while (1) {
		loop = 0;
		for (int i = 0; i <= 101; i++) {
			for (int z = 0; z <= 101; z++) {
				date2[i][z] = 0;
			}
		}
		cin >> a >> b;
		if (a == 0 && b == 0) {
			goto end;
		}
		for (int i = 0; i < a; i++) {
			cin >> date[i];
		}
		x = 0;
		y = 0;
		while (1) {
			if (date[y][x] == '>') {
				if (date2[y][x] == 1) {
					goto b;
				}
				date2[y][x] = 1;
				x = x + 1;
			}
			if (date[y][x] == '<') {
				if (date2[y][x] == 1) {
					goto b;
				}
				date2[y][x] = 1;
				x = x - 1;
			}
			if (date[y][x] == 'v') {
				if (date2[y][x] == 1) {
					goto b;
				}
				date2[y][x] = 1;
				y = y + 1;
			}
			if (date[y][x] == '^') {
				if (date2[y][x] == 1) {
					goto b;
				}
				date2[y][x] = 1;
				y = y - 1;
			}
			if (date[y][x] == '.') {
				goto a;
			}
		}
		b:;
		loop = 1;
		a:;
		if (loop == 1) {
			cout << "LOOP" << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}
end:;
}

C++: #include<iostream>

using namespace std;
int H, W;
int x = 0, y = 0;
int rog[100][100];
bool check(){
	if (rog[x][y] == 0){
		cout << "LOOP" << endl;
		return true;
	}
	
		return false;
	
}
int main(){
	char ma[100][100];

	while (cin >> H >> W,W+H){

		int x = 0, y = 0;
		ma[100][100] = {};
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> ma[j][i];
				rog[j][i] = 1;
			}
		}
		while (1){
			if (ma[x][y] == '>'){
				x++;
				if (check())break; 
			}
			else if(ma[x][y]=='v'){
				y++;
				if (check()) break; 
			}
			else if (ma[x][y] == '<'){
				x--;
				if (check()) break; 
			}
			else if (ma[x][y] == '^'){
				y--;
				if (check())break; 
			}
			else {
				cout << x << " " << y << endl;
				break;
			}
			
			rog[x][y] = 0;

		}
	}
}

C++: #include <iostream>
#include <set>
#define PI pair<int,int>
using namespace std;
char m[101][101];
int main()
{
  int h,w,i,j;
  for(;;){
    cin >> h >> w;
    if(h==0 && w==0) break;
    for(i=0;i<h;i++){
      cin >> m[i];
    }
    i = j = 0;
    set< PI > s;
    s.insert(PI(i,j));
    while(m[i][j] != '.'){
      switch(m[i][j]){
      case '>': j++; break;
      case '<': j--; break;
      case '^': i--; break;
      case 'v': i++; break;
      }
      if(m[i][j] == '.') {
	cout << j << " " << i << endl;
	break;
      }
      if(s.find(PI(i,j)) != s.end()){
	cout << "LOOP" << endl;
	break;
      }
      s.insert(PI(i,j));
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int h,w;
	while(cin>>h>>w,w||h){
		string a;
		for(int i=0;i<w;i++){
			for(int j=0;j<h;j++){
				cin>>a[i][j];
			}
		}
		bool flag=true;
		int i=0,j=0;
		while(flag){
			flag=true;
			if(a[i][j]=='v'){
				i++;
				a[i][j]='!';
			}
			if(a[i][j]=='>'){
				j++;
				a[i][j]='!';
			}
			if(a[i][j]=='<'){
				j--;
				a[i][j]='!';
			}
			if(a[i][j]=='^'){
				i--;
				a[i][j]='!';
			}
			if(a[i][j]=='.'){
				break;
			}
			if(a[i][j]=='!'){
				flag=false;
			}
		}
		if(!flag){
			cout<<"LOOP"<<endl;
		}
		else{
			cout<<j<<' '<<i<<endl;
		}
	}
}

C++: #include <iostream>

int main(int argc, char **argv)
{
	int h, w;
	int x = 0, y = 0;
	char tiles[100][100];
	bool throughed[100][100] = {};
	bool loop = false;
	bool end = false;
	while(std::cin >> h >> w, h+w != 0){
		x = 0;
		y = 0;
		for(int i = 0; i < 100; i++){
			for(int j = 0; j < 100; j++){
				throughed[j][i] = false;
			}
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				std::cin >> tiles[j][i];
			}
		}
		while(true){
			if(throughed[x][y]){
				loop = true;
				break;
			}
			throughed[x][y] = true;
			switch(tiles[x][y]){
				case '.':
					end = true;
					break;
				case '^':
					y--;
					break;
				case 'v':
					y++;
					break;
				case '<':
					x--;
					break;
				case '>':
					x++;
					break;
			}
			if(end){
				break;
			}
		}
		if(loop){
			std::cout << "LOOP" << std::endl;
		}else{
			std::cout << x << " " << y << std::endl;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define debug(A) puts(A)
#define debugp(A,B) printf(A,B)
#define debugs(A,B) scanf(A,B)
using namespace std;

int main() {
  int mapx, mapy;
  int x, y, tmp0 = 0, tmp1 = 0;
  char map[150][150] = {0}, tmpc = 1;
  scanf("%d %d", &mapx, &mapy);
  while (mapx+mapy) {
    scanf("%c", &tmpc);
    while (tmp0 < mapx) {
      tmp1 = 0;
      while (tmp1 < mapy) {
        scanf("%c", &map[tmp0][tmp1]);
        tmp1++;
      }
      scanf("%c", &tmpc);
      tmp0++;
    }
    tmp0 = 0, tmp1 = 0, tmpc = 1;
    x = 0, y = 0;
    while (tmpc) {
      if (map[x][y] == '>') y++;
      else if (map[x][y] == '<') y--;
      else if (map[x][y] == '^') x--;
      else if (map[x][y] == 'v') x++;
      else if (map[x][y] == '.') tmpc = 0;
      else tmpc = 0;
      // debugp("Debug: %c %d %d\n", map[x][y], (x+1), (y+1));
    }
    printf("%d %d\n", (x+1), (y+1));
    scanf("%d %d", &mapx, &mapy);
  }
  return 0;
}