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<string>
using namespace std;

#define POS y*w+x

int main(){
while(1){
	int w, h;
	string str;
	getline( cin, str );
	sscanf( str.c_str(), "%d %d", &h, &w );
	if( (h==0)&&(w==0) ) break;

	char *data = new char[w*h];
	// data input
	for( int y=0; y<h; y++ ){
		getline( cin, str );
		for( int x=0; x<w; x++ ){
			data[POS] = str.c_str()[x];
		}
	}

	// search
	int p = 0, cnt=0;
	while( data[p] != '.' ){
		switch(data[p]){
		case '>':
			p++;
			break;
		case '<':
			p--;
			break;
		case 'v':
			p+=w;
			break;
		case '^':
			p-=w;
			break;
		}
		cnt++;
		if( cnt > w*h ) break;
	}

	// output
	if( cnt > w*h ){
		cout << "LOOP" << endl;
	}else{
		cout << p%w << " " << p/w << endl;
	}

	delete[] data;
	data = 0;
}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#define W_MAX 100
#define H_MAX 100
char map[H_MAX+1][W_MAX+1];
char gx,gy;
int solve(int posX,int posY)
{
	if(map[posY][posX]=='x')
		return 0;
	map[posY][posX]='x';
	if(map[posY][posX]=='^')
		return solve(posX,posY-1);
	else if(map[posY][posX]=='v')
		return solve(posX,posY+1);
	else if(map[posY][posX]=='>')
		return solve(posX+1,posY);
	else if(map[posY][posX]=='<')
		return solve(posX-1,posY);
	gx=posX;gy=posY;
	return 1;
}
int main(void)
{
	int w,h,k;
	char str[101];
	while(true){
		scanf("%d%d",&h,&w);
		if(h==0||w==0)break;
		for(k=0;k<h;k++)
		{
			scanf("%s",&str);
			strcpy(map[k],str);
		}
		if(solve(0,0)==1)printf("%d %d\n",gx,gy);
		else printf("LOOP\n");
	}
}

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

int main(){

  int h, w, v[100][100], x, y;
  string str[100];

  while(cin >> h >> w){
    if(h == 0) break;
    for(int i=0; i<h; i++){
      fill(&v[i][0], &v[i][w], 0);
    }

    getline(cin, str[0]);
    for(int i=0; i<h; i++){
      getline(cin, str[i]);
    }

    x = 0;
    y = 0;
    while(1){
      if(str[x][y] == '.'){
        cout << y << " " << x << endl;
        break;
      }
      else if(v[x][y] == 1){
        cout << "LOOP" << endl;
        break;
      }

      v[x][y] = 1;      

      if(str[x][y] == '^') x--;
      else if(str[x][y] == '>') y++;
      else if(str[x][y] == 'v') x++;
      else if(str[x][y] == '<') y--;
    }
  }

  return 0;

}

C++: #include <stdio.h>
#define U 1
#define D 2
#define R 3
#define L 4
#define MAX 100

int main(void){
    int dx[L+1] = {0,0,0,1,-1};
    int dy[L+1] = {0,-1,1,0,0};
    int pnl[MAX][MAX];
    int visited[MAX][MAX];
    char buf[MAX+1];
    int h,w,x,y,dir;
    
    while (scanf("%d %d",&h, &w)){
        if (h==0 && w==0) break;
        // load
        for (int i=0; i<h; i++){
            scanf("%s", buf);
            for (int j=0; j<w; j++){
                visited[j][i] = pnl[j][i] = 0;
                switch (buf[j]){
                    case '^' : pnl[j][i]=U; break;
                    case 'v' : pnl[j][i]=D; break;
                    case '>' : pnl[j][i]=R; break;
                    case '<' : pnl[j][i]=L; break;
                }
            }
        }
        // move
        x = y = 0;
        while(pnl[x][y] && !visited[x][y]){
            visited[x][y]=1;
            dir = pnl[x][y];
            x += dx[dir];
            y += dy[dir];
        }
        if (pnl[x][y]){
            printf("LOOP\n");
        } else {
            printf("%d %d\n", x,y);
        }
    }
    
    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
char a[8000][8000]; int h, w, loop, cx, cy;
int main() {
	while (true) {
		cin >> h >> w;
		if (!h) { break; }
		memset(a, ' ', sizeof(a));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> a[i][j];
			}
		}
		cx = 0; cy = 0; loop = 0;
		while (true) {
			if (loop > 15000000) { cout << "LOOP" << endl; break; }
			if (a[cy][cx] == '.') { cout << cx << ' ' << cy << endl; break; }
			if (a[cy][cx] == '<') { cx--; }
			if (a[cy][cx] == '>') { cx++; }
			if (a[cy][cx] == '^') { cy--; }
			if (a[cy][cx] == 'v') { cy++; }
			loop++;
		}
	}
}

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

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

posn* next(posn *now, char bord[128][128], int W, int H) {
	posn* ans;

	ans = (posn*)malloc(sizeof(posn));

	switch(bord[now->y][now->x]) {
		case '>' : if(now->x < W - 1)
					   ans->x = now->x + 1;
				   else
					   ans->x = now->x;
				   break;

		case '<' : if(now->x > 0)
					   ans->x = now->x - 1;
				   else
					   ans->x = now->x;
				   break;

		case 'v' : if(now->y < H - 1)
					   ans->y = now->y + 1;
				   else
					   ans->y = now->y;
				   break;

		case '^' : if(now->y > 0)
					   ans->y = now->y - 1;
				   else
					   ans->y = now->y;
				   break;

		case '.' : ans->x = now->x;
				   ans->y = now->y;
	}

	return ans;
}

int main() {
	int W , H;
	char bord[128][128];
	int count = 0;
	posn now;
	posn *temp;

	int i, j;

	while(1) {
		scanf("%d %d", &H, &W);
		if(W == 0 && H == 0)
			break;

		for(i = 0; i < H; i++)
			scanf("%s", bord[i]);

		now.x = 0; now.y = 0;

		count = 0;
		while(count < W * H) {
			temp = next(&now, bord, W, H);
		
			if(temp->x == now.x && temp->y == now.y)
				break;
			
			else {
				now.x = temp->x;
				now.y = temp->y;
			}

			count++;
			free(temp);
		}

		if(count == W * H)
			printf("LOOP\n");
		else
			printf("%d %d\n", now.x, now.y);

	}
	
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)




int main(void){
	int w,h;
	char map[100][100];
	while(cin >> w >> h,w|h){
		rep(j,h)
			rep(i,w)
				cin >> map[i][j];
		int x=0,y=0;
		while(true){
			if(map[x][y]=='@'){
				cout << "LOOP" << endl;
				break;
			}
			if(map[x][y]=='>'){
				x++;
				map[x-1][y]='@';
			}else if(map[x][y]=='<'){
				x--;
				map[x+1][y]='@';
			}else if(map[x][y]=='v'){
				y++;
				map[x][y-1]='@';
			}else if(map[x][y]=='^'){
				y--;
				map[x][y+1]='@';
			}else{
				cout << x << " " << y << endl;
				break;
			}
		}
	}
	return 0;
}

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

int H, W;

void solve() {
	string b[100];
	for (int i = 0; i < H; i++) {
		cin >> b[i];
	}

	bool visited[100][100] = {0};
	int x = 0, y = 0;

	while (b[y][x] != '.') {
		if (visited[y][x]) {
			cout << "LOOP" << endl;
			return;
		}
		visited[y][x] = true;
		if (b[y][x] == '^') y--;
		if (b[y][x] == 'v') y++;
		if (b[y][x] == '<') x--;
		if (b[y][x] == '>') x++;
	}

	cout << x << " " << y << endl;
}

int main() {
	while (cin >> H >> W , H) {
		solve();
	}
}