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;

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

int main()
{
  int h, w;

  while (cin >> h >> w, h + w){
  	int dx = 0, dy = 0;
    string tile[101];
    bool done[101][101], flag = false;

    REP(i, h){
      REP(j, w) done[i][j] = false;
    }
    REP(i, h) cin >> tile[i];
    while (tile[dy][dx] != '.'){
      if (done[dy][dx]){
        flag = true;
        cout << "LOOP" << endl;
        break;
      }
      done[dy][dx] = true;
      if (tile[dy][dx] == '<') dx--;
      if (tile[dy][dx] == '>') dx++;
      if (tile[dy][dx] == '^') dy--;
      if (tile[dy][dx] == 'v') dy++;
    }
    if (flag) continue;
    cout << dx << " " << dy << endl;
  }
}

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

enum Tile{
    RIGHT, LEFT, UP,DOWN, FINISH,UNKOEN
};

void MagicTile(int width, int height){
    int x=0,y=0,i=0,j=0;
    string string;
    Tile t;
    Tile *map = new Tile[width * height];
    
    for(i=0;i<height;i++){
        cin >> string;
        //cout <<string <<endl;
        for(j=0;j<width;j++){
            switch (string[j]){
                case '>': t = RIGHT;break;
                case '<': t = LEFT;break;
                case '^': t = UP;break;
                case 'v': t = DOWN;break;
                case '.': t = FINISH;break;
                //default: t = UNKOEN;
            }
            map[j+i*width] = t;
        }
        
    }
    int count=0,total=width*height;
    while(map[x+y*width]!=FINISH){
        switch (map[x+y*width]){
            case RIGHT: x++;break;
            case LEFT: x--;break;
            case UP: y--;break;
            case DOWN: y++;break;
            case FINISH: break;
        }
        count++;
        if(total<=count) break;
    }
    if(count==total){
        cout <<"LOOP"<<endl;
    }
    else {
        cout << x <<" "<< y << endl;
    }
}


int main(){
    int m,n;
    cin >> m >> n;
    cin.ignore();
    while(!(m==0 && n==0)){
        MagicTile(n,m);
        cin >> m >> n;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	int w, h, i, j, c, x, y;
	char f[100][100];
	bool b;
	while (cin >> w >> h)
	{
		if (w == 0 && h == 0) break;
		x = y = 0;
		b = false;
		c = 0;
		for (i = 0; i < w; i++)
			for (j = 0; j < h; j++)
				cin >> f[i][j];
		while (c <= w*h)
		{
			switch (f[y][x])
			{
			case '>':
				x++;
				break;
			case '^':
				y--;
				break;
			case '<':
				x--;
				break;
			case 'v':
				y++;
				break;
			default:
				cout << x << " " << y << endl;
				b = true;
				break;
			}
			if (b) break;
			c++;
		}
		if (!b) cout << "LOOP" << endl;
	}
}

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

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	int r, c;
	while(cin >> r >> c && (r || c)) {
		char board[110][110];
		bool b[110][110];
		rep(i,r) {
			rep(j,c) {
				b[i][j] = 0;
			}
		}

		rep(i,r) {
			string s;
			cin >> s;
			rep(j,c) {
				board[i][j] = s[j];
			}
		}
		
		char ch = board[0][0];
		int y = 0, x = 0;
		while(ch != '.' && !b[y][x]) {
			b[y][x] = 1;
			switch(ch) {
			case '>' : 
				x++;
				break;
			case '<' :
				x--;
				break;
			case '^' :   
				y--;
				break;
			case 'v' : 
				y++;
				break;
			default :
				break;
			}
			ch = board[y][x];
		}
		if(b[y][x]) cout << "LOOP" << endl;
		else cout << x << " " << y << endl;
	}
	return 0;
}

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

using namespace std;

int main(){

	int w,h;
	while(cin>>w>>h&&!(w==0&&h==0)){
		vector<string> field;
		string str;
		for(int i = 0; i < h; i++){
			cin>>str;
			field.push_back(str);
		}
		bool isPassed[200][200];
		memset(isPassed,0,sizeof(isPassed));
		int sy,sx;
		sy=sx=0;
		bool f=true;
		while(1){
			if(isPassed[sy][sx]){
				f=false;
				break;
			}
			isPassed[sy][sx]=true;
			if(field[sy][sx]=='>'){
				sx++;
			}
			else if(field[sy][sx]=='<'){
				sx--;
			}
			else if(field[sy][sx]=='v'){
				sy++;
			}
			else if(field[sy][sx]=='^'){
				sy--;
			}
			else
				break;
		}
		if(!f){
			cout<<"LOOP"<<endl;
		}
		else
			cout<<sx<<" "<<sy<<endl;
	}

	return 0;
}

C++: #include<iostream>

using namespace std;

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

int main(){

  int x,y;

  while(cin >> y >> x && x+y){
    char data[y][x];
    int come[y][x];
    for(int i = 0; i < y; i++){
      for(int j = 0; j < x; j++){
	cin >> data[i][j];
	come[i][j] = 0;
      }
    }

    Point point;
    point.x = point.y = 0;
    int status = 0;
    while(1){
      come[point.y][point.x] = 1;
      if(data[point.y][point.x] == '^') point.y--;
      else if(data[point.y][point.x] == 'v') point.y++;
      else if(data[point.y][point.x] == '>') point.x++;
      else if(data[point.y][point.x] == '<') point.x--;
      else if(data[point.y][point.x] == '.') break;
      if(come[point.y][point.x]){
	status = 1;
	break;
      }
    }
    if(status) cout << "LOOP" << endl;
    else cout << point.x << " " << point.y << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
using namespace std;
int main(){
char in[100][100];
int a,b;
while(cin>>a>>b,a||b){
rep(i,a){
rep(j,b){
char in1;
cin>>in1;
in[i][j]=in1;
}
}
//cout<<in[1][0]<<endl;
int x=0,y=0;
while(1){
if(in[x][y]=='.'){cout<<y<<" "<<x<<endl;break;}
else if(in[x][y]=='1'){cout<<"LOOP"<<endl;break;}
else if(in[x][y]=='<'){in[x][y]='1';y--;}
else if(in[x][y]=='>'){in[x][y]='1';y++;}
else if(in[x][y]=='^'){in[x][y]='1';x--;}
else if(in[x][y]=='v'){in[x][y]='1';x++;}
//cout<<1<<endl;
}
}
}

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;
	}
	else{
		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[i][j];
				rog[i][j] = 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;

		}
	}
	return 0;
}