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 <vector>
#include <string>
#include <cstdio>

using namespace std;

const char arrow[] = {'>', '<', 'v', '^'};
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

int main(){
	int H, W;
	while(cin >> H >> W, H+W){
		vector<string> tile(H);
		bool visit[101][101] = {false};
		for(int i = 0; i < H; i++){
			cin >> tile[i];
		}
		int x = 0, y = 0;
		while(visit[y][x] != true){
			visit[y][x] = true;
			for(int i = 0; i < 4; i++){
				if(tile[y][x] == arrow[i]){
					x += dx[i];
					y += dy[i];
					break;
				}
			}
		}
		if(tile[y][x] == '.'){
			cout << x << ' ' << y << endl;
		}else{
			cout << "LOOP" << endl;
		}
	}

	return 0;
}

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

int main(){
	int w,h,x,y;
	char tile[100][100];
	bool use[100][100];
	bool flg;
	
	while(1){
	 cin>>w>>h;
	 for(y=0;y<h;y++){
	  for(x=0;x<w;x++){
	   cin>>tile[x][y];
	   use[x][y]=false;
	  }
	 }
	 
	 x=0;y=0;flg=false;
	 do{
	  if(use[x][y]){cout<<"LOOP"<<endl;break;}
	  use[x][y]=true;
	  switch(tile[x][y]){
		case '.':
		flg=true;
		break;

		case '>':
		x+=1;
		break;

		case '<':
		x-=1;
		break;

		case '^':
		y-=1;
		break;

		case 'v':
		y+=1;
		break;
	  }
	 }while(flg);
	}
}

C++: #include <iostream>

int main(int argc, char **argv)
{
	int h, w;
	int x = 0, y = 0;
	char tiles[100][100];
	bool throughed[100][100] = {};
	bool loop = false;
	bool end = false;
	while(std::cin >> h >> w, h+w != 0){
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				std::cin >> tiles[j][i];
			}
		}
		while(true){
			if(throughed[x][y]){
				loop = true;
				break;
			}
			throughed[x][y] = true;
			switch(tiles[x][y]){
				case '.':
					end = true;
					break;
				case '^':
					y--;
					break;
				case 'v':
					y++;
					break;
				case '<':
					x--;
					break;
				case '>':
					x++;
					break;
			}
			if(end){
				break;
			}
		}
		if(loop){
			std::cout << "LOOP" << std::endl;
		}else{
			std::cout << x << " " << y << std::endl;
		}
	}
	return 0;
}

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

int main(){
	int H,W;
	while(1){
		cin>>H>>W;
		if(H==0 && W==0)break;
		char ct[H][W];
		int flg[H][W];
		int error=0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>ct[i][j];
				flg[i][j]=0;
			}
		}
		int nowX=0,nowY=0,ansX=0,ansY=0;
		while(1){
			if(flg[nowY][nowX]==1){
				cout<<"LOOP"<<endl;
				error=1;
				break;
			}
			flg[nowY][nowX]=1;
			if(ct[nowY][nowX]=='>'){
				nowX++;
			}else if(ct[nowY][nowX]=='<'){
				nowX--;
			}else if(ct[nowY][nowX]=='^'){
				nowY--;
			}else if(ct[nowY][nowX]=='v'){
				nowY++;
			}else if(ct[nowY][nowX]=='.'){
				ansX=nowX;
				ansY=nowY;
				break;
			}
		}
		if(error!=1){
			cout<<nowX<<" "<<nowY<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		int x=0,y=0;
		int co=0;
		while(co!=20000){
			if(in[x][y]=='>')y++;
			else if(in[x][y]=='<')y--;
			else if(in[x][y]=='v')x++;
			else if(in[x][y]=='^')x--;
			else break;
			co++;
		}
		if(co==20000)cout<<"LOOP"<<endl;
		else cout<<y<<" "<<x<<endl;
	}
}

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

using namespace std;

int main(int argc, char **argv)
{
	int *array1, *array2, n, m, tmp, i, j;
	char w;
	
	while(1){
		cin >> n >> m;
		if(n == 0 || m == 0){
			break;
		}
		
		array1 = (int *)calloc(n*m, sizeof(int));
		array2 = (int *)calloc(n*m, sizeof(int));
		
		for(i = 0; i < n; i++){
			for(j = 0, tmp = i*m; j < m; j++){
				cin >> w;
				
				if(w == '>'){
					array1[tmp+j] = tmp + j + 1;
				} else if(w == 'v'){
					array1[tmp+j] = tmp + j + m;
				} else if(w == '<'){
					array1[tmp+j] = tmp + j -1;
				} else if(w == '^'){
					array1[tmp+j] = tmp + j - m;
				} else {
					array1[tmp+j] = -1;
				}
			}
		}
		
		tmp = array1[0];
		array2[0] = 1;
		while(1){
			if(array2[tmp] == 1){
				cout << "LOOP" << endl;
				break;
			} else if(array1[tmp] == -1){
				i = tmp % m;
				j = (int)(tmp / m);
				cout << i << " " << j << endl;
				break;
			}
			
			array2[tmp] = 1;
			tmp = array1[tmp];
		}		
		
		free(array1);
		free(array2);
	}
	
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main() {

  int w, h;
  while( cin >> h >> w, w+h ) {
    char room[10][10];
    bool flag[10][10];
    int now_x = 0, now_y = 0;

    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) {
	cin >> room[i][j];
	flag[i][j] = false;
      }
    }

    while(1) {
      if( flag[now_y][now_x] || room[now_y][now_x] == '.' ) break;
      char c = room[now_y][now_x];
      flag[now_y][now_x] = true;
     

      if( c == '>' ) {
	while( room[now_y][now_x] == c ) {
	  now_x++;
	}
      }
      if( c == '<' ) {
	while( room[now_y][now_x] == c ) {
	  now_x--;
	}
      }
      if( c == 'v' ) {
	while( room[now_y][now_x] == c ) {
	  now_y++;
	}
      }
      if( c == '^' ) {
	while( room[now_y][now_x] == c ) {
	  now_y--;
	}
      }
      printf("x : %d y : %d\n", now_x, now_y);
    }

    if( room[now_y][now_x] != '.' ) cout << "LOOP" << endl;
    else cout << now_x << " " << now_y << endl;
  }
}

C++: #include <iostream>

using namespace std;
/** Problem0104 : Magical Tiles **/
int main()
{
	char room[110][110];
	int w, h, x, y;
	
	while (cin >> h >> w, w != 0 && h != 0) {
		for (int y=0; y<h; y++) {
			for (int x=0; x<w; x++) {
				cin >> room[x][y];
			}
		}

		x=0; y=0;
		while (1) {
			if (room[x][y] == '>') {
				room[x][y] = 'L';
				x++;
			} else if (room[x][y] == '<') {
				room[x][y] = 'L';
				x--;
			} else if (room[x][y] == '^') {
				room[x][y] = 'L';
				y--;
			} else if (room[x][y] == 'v') {
				room[x][y] = 'L';
				y++;
			} else if (room[x][y] == 'L') {
				cout << "LOOP" << endl;
				break;
			} else if (room[x][y] == '.') {
				cout << x << " " << y << endl;
				break;
			}
		}
	}
}