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;
    
    while (cin >> H >> W && H + W != 0) {
        string dummy; getline(cin, dummy);
        
        char room[101][101];
        for (int h = 0; h < H; ++h) {
            for (int w = 0; w < W; ++w) {
                cin >> room[h][w];
            }
        }

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

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

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

    return 0;
}

C++: // 2011/01/07 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int W, H;
		cin >> W >> H;
		if(W==0&&H==0)
			break;

		char til[101][101];
		for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
				cin >> til[i][j];

		bool flg[101][101];
		for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
				flg[i][j] = false;

		int x = 0;
		int y = 0;
		while(true){
			if(flg[y][x]){
				cout << "LOOP" << endl;
				break;
			}

			flg[y][x] = true;

			if(til[y][x]=='>')
				x++;
			else if(til[y][x]=='<')
				x--;
			else if(til[y][x]=='v')
				y++;
			else if(til[y][x]=='^')
				y--;
			else{
				cout << x << ' ' << y << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include <stdio.h>

int main(void){	
	int x, y;
	int w, h;
	int loop;
	char tile[101][101];


	while(1){
		x = 0;
		y = 0;
		loop = 0;

		for(int i=0; i<101; i++){
			for(int j=0; j<101; j++){
				tile[i][j] = 0;
			}
		}

		scanf("%d %d", &w, &h);
		if(w == 0 && h == 0) break;
		if(w == 0 || h == 0){
			printf("0 0\n");
			continue;
		}
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				scanf(" %c", &tile[j][i]);
			}
		}

		while(1){
			char c = tile[x][y];
			tile[x][y] = 'x';

			if(c == '>') x++;
			else if(c == '<') x--;
			else if(c == '^') y--;
			else if(c == 'v') y++;
			else if(c == '.') break;
			else{
				loop = 1;
				break;
			}
		}
		if(loop == 0)printf("%d %d\n", x, y);
		else printf("LOOP\n");
	}
	return 0;
}

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

using namespace std;

int main(){
    int w,h;
    int i,j;
    while(1){
        cin >> w;
        cin >> h;
        if(w == 0) break;
        vector< vector<char> > v(w,vector<char>(h));
        for(j=0;j<h;++j){
            for(i=0;i<w;++i){
                cin >> v[i][j];
            }
        }
        int mi = 0, mj = 0;
        while(true){
            char c = v[mi][mj];
            v[mi][mj] = '#';
            if(c == '>') mi++;
            else if(c == '<') mi--;
            else if(c == '^') mj--;
            else if(c == 'v') mj++;
            else if(c == '#'){
                cout << "LOOP";
                break;
            } else if( c == '.' ){
                cout << mi << ' ' << mj << endl;
                break;
            }
        }
    }
    return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<cstring>
using namespace std;
int W,H;
char fie[102][102];
int cost[102][102];
char df[]={'>','v','<','^'};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
  while(1){
    cin >> H >> W;
    memset(fie,-1,sizeof(fie));
    memset(cost,0,sizeof(cost));
    if(W==0 && H==0) break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> fie[j][i];
      }
    }
    int x=0,y=0;
    bool f=false;
    cost[x][y]=1;
    while(fie[x][y]!='.'){
      for(int i=0;i<4;i++){
	
	if(fie[x][y]==df[i]){
	  x+=dx[i];
	  y+=dy[i];
	}
      }
      if(cost[x][y]){
	f=true;
	break;
      }
      cost[x][y]=1;
    }
    if(!f) printf("%d %d\n",x,y);
    else puts("LOOP");
  }
}

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

    int main (){
        int h, w;
        int i, j;
        int x = 0, y = 0;
        char c[100][100];
        while(1){
            x = 0; y = 0;
            cin >> h >> w;
            if(h == 0 && w == 0){
                break;
            }
            for(i = 0; i < h; i++){
                for(j = 0; j < w; j++){
                    cin >> c[i][j];
                }
            }
            
            while(1){
                if(c[y][x] == '<'){
                    c[y][x] = 'r';
                    x--;
                }
                if(c[y][x] == '>'){
                    c[y][x] = 'r'; 
                    x++;
                    }
                if(c[y][x] == 'v'){
                    c[y][x] = 'r';
                    y++;
                    }
                if(c[y][x] == '^'){
                    c[y][x] = 'r';
                    y--;
                    }
                if(c[y][x] == '.'){
                    cout << x << " " << y << endl;
                    break;
                }
                if(c[y][x] == 'r'){
                    cout << "LOOP" << endl;
                    break;
                }
            }
        }

    return 0;    
    }

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

int main(){
  int W,H;
  while(scanf("%d%d", &H, &W)){
    if ((H == 0) && (W == 0)){
      break;
    }
    vector<vector<char> > m(H, vector<char>(W, ' '));
    vector<vector<int> > v(H, vector<int>(W, 0));
    for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
        scanf(" %c", &(m[i][j]));
      }
    }
    int x = 0, y = 0;
    bool loop = false;
    while(m[y][x] != '.'){
      if (v[y][x] != 0){
        loop = true;
        printf("LOOP\n");
        break;
      }else{
        v[y][x] = 1;
        if (m[y][x] == '>'){
          x++;
	}else if (m[y][x] == 'v'){
          y++;
	}else if (m[y][x] == '<'){
          x--;
	}else if (m[y][x] == '^'){
          y--;
	}
      }
    }
    if (!loop){
      printf("%d %d\n", x, y);
    }
  }
  return 0;
}