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 <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int h,w;
  while(cin>>h>>w,h+w) {
    char ba[w][h];
    REP(y,h) {
      REP(x,w) {
        cin >> ba[x][y];
      }
    }
    int x = 0, y = 0;
    int dx[] = {0,1,0,-1};
    int dy[] = {-1,0,1,0};
    char aa[] = {'^','>','v','<'};
    map<char,int> hoge;
    REP(i,4)
      hoge[aa[i]] = i;
    int f[w][h];
    memset(f,0,sizeof(f));
    while(true) {
      printf("%d,%d \n",x,y);
      if (f[x][y]) break;
      if (ba[x][y] == '.') break;

      f[x][y]=1;
      int aa = hoge[ba[x][y]];
      x += dx[aa];
      y += dy[aa];
    }
    if (f[x][y]) cout << "LOOP" << endl;
    else cout << x << " " << y << endl;
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
bool ariv[101][101];
P end(vector<string> grid,int x, int y){
  if(ariv[y][x]) return P(-1,-1);
  else ariv[y][x] = true;
  if(grid[y][x]=='.') return P(x,y);
  if(grid[y][x]=='>') return end(grid,x+1,y);
  if(grid[y][x]=='<') return end(grid,x-1,y);
  if(grid[y][x]=='^') return end(grid,x,y-1);
  if(grid[y][x]=='v') return end(grid,x,y+1);
}
void outp(vector<string> grid,int x,int y){
 P point = end(grid,x,y);
 if(point.first==-1) cout<<"LOOP"<<endl;
 else printf("%d %d\n",point.first,point.second);
}
int main(void){
  int H,W;
  while(cin>>H>>W){
    if(H==0) break;
    vector<string> grid;
    memset(ariv,0,sizeof(ariv));
    REP(y,H){
      string tmp;
      cin>>tmp;
      grid.push_back(tmp);
    }
    if(grid[0][0]=='.') printf("0 0\n");
    else if(grid[0][0]=='>')outp(grid,1,0);
    else if(grid[0][0]=='<')outp(grid,0,0);
    else if(grid[0][0]=='^')outp(grid,0,0);
    else if(grid[0][0]=='v')outp(grid,0,1);
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int h, w; 
	while (cin >> h >> w) {
		char map[114][514];
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				cin >> map[i][j];
		int i = 0, j = 0;
		for (int p = 1; p <= 10000; p++) {
			if (map[i][j] == '.') {
				cout << j << ' ' << i << endl;
				continue;
			}
			else if (map[i][j] == '>') j++;
			else if (map[i][j] == '<') j--;
			else if (map[i][j] == '^') i--;
			else if (map[i][j] == 'v') i++;
		}
		cout << "LOOP\n";
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
long h,w,a[101][101],f,i,j;
string s[101];
for(;;){
cin>>h>>w;
if(h==0)break;
for(i=0;i<h;i++)cin>>s[i];
for(i=0;i<h;i++)
for(j=0;j<w;j++)a[i][j]=0;
i=j=0;
a[i][j]=1;
for(;;){
if(s[i][j]=='>')j++;
else if(s[i][j]=='<')j--;
else if(s[i][j]=='^')i--;
else if(s[i][j]=='v')i++;
else{f=0;break;}
if(a[i][j]==1){f=1;break;}
a[i][j]=1;
}
if(f==0)cout<<j<<" "<<i<<endl;
else cout<<"LOOP"<<endl;
}
return 0;
}

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

int main() {
    int H, W;
    
    while (cin >> H >> W && H + W != 0) {
        cin.get();
        cin.get();
        vector<string> room;
        for (int h = 0; h < H; ++h) {
            string line;
            getline(cin, line);
            room.push_back(line);
        }

        int steps = 0;
        int x = 0, y = 0;
        bool loop = false;

        while (room[x][y] != '.') {
            if (room[x][y] == '!') {
                loop = true;
                break;
            }
            if (room[x][y] == '>') {
                room[x][y] = '!';
                y++;
            }
            if (room[x][y] == '<') {
                room[x][y] = '!';
                y--;
            }
            if (room[x][y] == '^') {
                room[x][y] = '!';
                x--;
            }
            if (room[x][y] == 'v') {
                room[x][y] = '!';
                x++;
            }
        }

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

C++: #include <iostream>
#include <utility>
#define x pos.second
#define y pos.first
using namespace std;

int main(){
    int h, w;

    while(cin >> h >> w, h != 0 || w != 0){
        char map[h][w];
        pair<int, int> pos;
        bool loop = false;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cin >> map[j][i];
            }
        }
        pos.first = 0;
        pos.second = 0;
        while(1){
            if(map[x][y] == '!'){
                loop = true;
                break;
            }
            if(map[x][y] == '.'){
                break;
            }
            if(map[x][y] == '>'){
                map[x][y] = '!';
                x++;
            }
            else if(map[x][y] == '<'){
                map[x][y] = '!';
                x--;
            }
            else if(map[x][y] == 'v'){
                map[x][y] = '!';
                y++;
            }
            else if(map[x][y] == '^'){
                map[x][y] = '!';
                y--;
            }
        }
        if(loop) cout << "LOOP" << endl;
        else cout << x << " " << y << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
using namespace std;
int main() {
	int H,W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) {
			break;
		}
		string tile[100];
		bool memo[100][100];
		for (int i = 0;i < H;i++) {
			cin >> tile[i];
			for (int j = 0;j < W;j++) {
				memo[i][j] = false;
			}
		}
		int x = 0;
		int y = 0;
		while (true) {
			if (memo[x][y]) {
				cout << "LOOP" << endl;
				break;
			}
			if (tile[x][y] == '.') {
				cout << y << " " << x << endl;
				break;
			}
			memo[x][y] = true;
			if (tile[x][y] == '>') {
				y++;
			}
			if (tile[x][y] == '<') {
				y--;
			}
			if (tile[x][y] == '^') {
				x--;
			}
			if (tile[x][y] == 'v') {
				x++;
			}

		}
	}
	return 0;

}