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<stdio.h>
char t[100][100];
int main(){
	int h,w;
	int i,j;
	while(1){
	scanf("%d %d",&h,&w);
	if(h==0)return 0;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			scanf(" %c",&t[i][j]);
		}
	}
	int x=0,y=0;
	int c=1;
	while(t[x][y]!='.'){
		char ch=t[x][y];
		switch(ch){
		case '>':y++;break;
		case '<':y--;break;
		case 'v':x++;break;
		case '^':x--;break;
		}
		c++;
		if(c>w*h)break;
	}
	if(t[x][y]=='.')printf("%d %d\n",y,x);
	else printf("LOOP\n");
	}
}

C++: #include <cstdio>
#include <utility>
#include <vector>
#include <string>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
is(string &s){int c; s = "";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo

typedef vector<string> v;

void slip(v &r) {
	int x = 0, y = 0;
	for (;;) {
		char c = r[y][x];
		r[y][x] = 'X';
		switch (c) {
		case '.': out(x, ' ', y, '\n'); return;
		case 'X': out("LOOP\n"); return;
		case '>': x += 1; break;
		case '<': x -= 1; break;
		case 'v': y += 1; break;
		case '^': y -= 1; break;
		}
	}
}

int main() {
	for (int H, W; H = in(), W = in(), H || W;) {
		v r(H);
		for (auto &s: r)
			scan(s);
		slip(r);
	}
}

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, tmp2 = 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, tmp2 = 0, tmpc = 1;
    x = 0, y = 0;
    while (tmpc && tmpc != 100) {
      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 = 100;
      map[x][y] = 1;
      // else tmpc = 0;
      tmp2++;
      // debugp("Debug: %c %d %d\n", map[x][y], (x+1), (y+1));
    }
    if (tmpc == 100) puts("LOOP");
    else printf("%d %d\n", (x+1), (y+1));
    scanf("%d %d", &mapx, &mapy);
  }
  return 0;
}

C++: #include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	char map[100][100];
	int w, h, x = 0, y = 0, lx, ly, c;

	while (1){
		c = 0;

		cin >> h >> w;

		if (w == 0 && h == 0)break;

		//input
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> map[i][j];
			}
		}

		//detect
		while(1){
			c++;
			
			if (c > w*h){
				lx = -1;
				ly = -1;
				break;
			}

			switch (map[y][x]){
			case '>':x++; break;
			case '<':x--; break;
			case '^':y--; break;
			case 'v':y++; break;
			}

			if (map[y][x] == '.'){
				lx = x; ly = y;
				break;
			}
		}

		if (lx == -1 && ly == -1){
			cout << "LOOP" << endl;
		}
		else{
			cout << lx << ' ' << ly << endl;
		}

		x = y = 0;
	}

	return 0;
}

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

int h,w;
char t[200][200];

int main(){
  while(cin>>h>>w,h||w){
    for(int i=0;i<h;i++){
      cin>>t[i];
    }

    int x=0,y=0;
    bool loopFlg = false;

    while(1){
      int nx = x;
      int ny = y;
      if(t[y][x] == '>') nx++;
      else if(t[y][x] == '<') nx--;
      else if(t[y][x] == '^') ny--;
      else if(t[y][x] == 'v') ny++;
      else if(t[y][x] == '?'){
        loopFlg = true;
        break;
      }
      else{
        break;
      }
      t[y][x] = '?';
      x = nx;
      y = ny;
    }

    if(loopFlg){
      cout<<"LOOP\n";
    }
    else{
      cout<<x<<" "<<y<<endl;
    }
  }
}

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

using namespace std;

typedef struct{
    int x;
    int y;
}dbint;

dbint move(char c){
    dbint mv;
    switch (c) {
        case '>':
            mv.x=1;
            mv.y=0;
            break;
        case '^':
            mv.x=0;
            mv.y=-1;
            break;
        case '<':
            mv.x=-1;
            mv.y=0;
            break;
        case 'v':
            mv.x=0;
            mv.y=1;
            break;
        default:
            mv.x=10;
            mv.y=10;
            break;
    }
    return mv;
}

int main() {
    int h,w,n=0;
    char c;
    dbint p,mv;
    vector< vector<char> > tiles;
    vector<char> temp;
    while(1){
        cin >> h >> w;
        p.x=0;p.y=0;
        if(h==0&&w==0) break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> c;
                temp.push_back(c);
            }
            tiles.push_back(temp);
            temp.clear();
        }
        while(1){
            mv=move(tiles[p.y][p.x]);
            if(mv.x>1) break;
            p.x+=mv.x;
            p.y+=mv.y;
            n++;
            if(n>h*w+100){
                n=-1;
                break;
            }
        }
        if(n>0) cout << p.x << " " << p.y << endl;
        else    cout << "LOOP" << endl;
        tiles.clear();
    }
    return 0;
}

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

using namespace std;

char board[101 * 101];

int solve(int pos) {
	char c = board[pos];
	board[pos] = '0';
	if (c == '.') return pos;
	else if (c == '0') return -1;
	else if (c == '>') return solve(pos + 1);
	else if (c== '<') return solve(pos - 1);
	else if (c == '^') return solve(pos - 101);
	else return solve(pos + 101);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;

	while (cin >> H >> W, H) {
		for(int y = 0; y < H; y++)
			for(int x = 0; x < W; x++)
				cin >> board[y*101 + x];
		int ret = solve(0);
		if (ret == -1)
			cout << "LOOP" << endl;
		else
			cout << ret % 101 << " " << ret / 101 << endl;
	}
}