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 <cstdio>
#include <iostream>
using namespace std;

int H, W;
char tiles[110][110];

int main() {
  while (scanf("%d %d", &H, &W), H || W) {
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
	cin >> tiles[i][j];
      }
    }
    
    int x, y;
    x = y = 0;

    /*
    puts("debug");
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
	cout << tiles[i][j];
      }
      cout << endl;
    }
    puts("debugend");
    */
    
    while (tiles[y][x] != '.' && tiles[y][x] != '*') {   
      // printf("debug %d %d %c\n", x, y, tiles[y][x]);

      char c = tiles[y][x];
      tiles[y][x] = '*';
      if (c == '>') {
	x++;
      } else if (c == '<') {
	x--;
      } else if (c == '^') {
	y--;
      } else if (c == 'v') {
	y++;
      }

    }

    // printf("%c\n", tiles[y][x]);
    
    if (tiles[y][x] == '.') {
      printf("%d %d\n", x, y);
    } else {
      puts("LOOP");
    }
  }
}

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

using namespace std;

/*
タイルは5種類
> : 東
< : 西
^ : 北
v : 南
. : なし

現在地のタイルが東西南北なら移動、
ピリオドなら終了して位置を出力する。

ループの判断
１度到達した位置は記録しておく。
２回目に到達したらループと判定する。

*/


struct Position {
	int xPos;
	int yPos;
};

Position moveNorth(Position pos) {
	return Position{ pos.xPos, pos.yPos - 1 };
}

Position moveSouth(Position pos) {
	return Position{ pos.xPos, pos.yPos + 1 };
}

Position moveWest(Position pos) {
	return Position{ pos.xPos - 1, pos.yPos };
}

Position moveEast(Position pos) {
	return Position{ pos.xPos + 1, pos.yPos };
}


int main() {
	int h, w;
	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}
		Position hitoPos = {};
		vector<vector<char>> tiles(h);
		vector<vector<bool>> mark(h);
		for (int i = 0; i < h; i++) {
			tiles[i] = vector<char>(w);
			mark[i] = vector<bool>(w);
		}

		for (auto& a : tiles) {
			for (auto &b : a) {
				cin >> b;
			}
		}

		while (!mark[hitoPos.yPos][hitoPos.xPos]) {
			mark[hitoPos.yPos][hitoPos.xPos] = true;
			switch (tiles[hitoPos.yPos][hitoPos.xPos])
			{
			case '>':
				hitoPos = moveEast(hitoPos);
				break;
			case '<':
				hitoPos = moveWest(hitoPos);
				break;
			case '^':
				hitoPos = moveNorth(hitoPos);
				break;
			case 'v':
				hitoPos = moveSouth(hitoPos);
				break;
			}
		}
		if (tiles[hitoPos.yPos][hitoPos.xPos] == '.') {
			cout << hitoPos.xPos << ' ' << hitoPos.yPos << endl;
		}
		else {
			cout << "LOOP" << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    char d[101][101],ch;int w,h,i,j;
    while(cin>>h>>w,h){
        for(i=0;i<h;i++)for(j=0;j<w;j++)cin>>d[i][j];i=j=0;
        while(d[i][j]!='.'&&d[i][j]!='X'){
            ch=d[i][j];d[i][j]='X';
            switch (ch){
                case '>':j++;break;
                case '<':j--;break;
                case 'v':i++;break;
                case '^':i--;
            }
        }(d[i][j]=='.')?(cout<<j<<" "<<i<<endl):(cout<<"LOOP"<<endl);
    }
}

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

bool check[101][101]={false};
int h,w;
char mas[101][101]={0};
pair<int, int> func(){
	/*for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				cout << mas[i][j];
			}
			cout << endl;
		}*/
	for(int i=0; i<h;){
		for(int j=0; j<w;){
			if(check[i][j]==true) return make_pair(-1,-1);
			check[i][j]=true;
			//cout << i << " " << j << endl;
			if(mas[i][j]=='>') j++;
			if(mas[i][j]=='<') j--;
			if(mas[i][j]=='v') i++;
			if(mas[i][j]=='^') i--;
			if(mas[i][j]=='.') return make_pair(i,j);
		}
	}
}

int main(){
	
	
	
	while(1){
		cin >> h >> w;
		if(h==0 && w==0) break;
		for(int i=0; i<h; i++){
			scanf("%s",&mas[i]);
		}
		
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				check[i][j]=false;
			}
		}
		pair<int, int> a=func();
		if(a.first==-1) cout << "LOOP" << endl;
		else cout << a.second << " " << a.first << endl;
	}
	return 0;
}

C++: #include<iostream>

int main()
{
	char tile[100][100];
	int n;
	while(1)
	{
		int r,c;
		std::cin>>r>>c;
		std::cin.ignore();
		if(r==0&&c==0)break;
		
		for(int i=0;i<r;i++)
		{
			char buf[101];
			std::cin.getline(buf,101);
			for(int j=0;j<c;j++)
			{
				tile[i][j]=buf[j];
			}
		}
		
		int x=0,y=0;
		bool moving=true;
		while(moving)
		{
			switch(tile[y][x])
			{
			case '.':
				std::cout<<x<<' '<<y<<std::endl;
				moving=false;
				break;
			case '>':
				tile[y][x]='1';
				x++;
				break;
			case '<':
				tile[y][x]='1';
				x--;
				break;
			case '^':
				tile[y][x]='1';
				y--;
				break;
			case 'v':
				tile[y][x]='1';
				y++;
				break;
			case '1':
				std::cout<<"LOOP"<<std::endl;
				moving=false;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;
char map[100][100];
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(){
	
	while (cin >> H >> W){

		int x = 0, y = 0;
		map[100][100] = {};
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> map[i][j];
				rog[i][j] = 1;
			}
		}
		while (1){
			if (map[x][y] == '>'){
				x++;
				if (check() == true){ break; }
			}
			else if(map[x][y]=='v'){
				y--;
				if (check() == true){ break; }
			}
			else if (map[x][y] == '<'){
				x--;
				if (check() == true){ break; }
			}
			else if (map[x][y] == '^'){
				y++;
				if (check() == true){ break; }
			}
			else {
				cout << x << " " << y << endl;
				break;
			}
			
			rog[x][y] = 0;

		}
	}
	return 0;
}

C++: #include<stdio.h>
int a,b,limx,limy;
char s[102][102];
int pass[102][102];
void check(int x,int y){
    printf("move to %d %d\n",x,y);
    if(pass[x][y]!=1){
        a=x,b=y;
        pass[x][y]=1;
        if(s[x][y]=='^'&&x-1>=0)
        check(x-1,y);
        if(s[x][y]=='v'&&x+1<limx)
        check(x+1,y);
        if(s[x][y]=='>'&&y+1<limy)
        check(x,y+1);
        if(s[x][y]=='<'&&y-1>=0)
        check(x,y-1);
    }
    else
    a=-1;
}
main(){
    int x,y,i,j;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)
        break;
        limx=x;limy=y;
        for(i=0;i<x;i++)
        for(j=0;j<y;j++)
        pass[x][y]=0;
        for(i=0;i<x;i++)
        scanf("%s",&s[i]);
        check(0,0);
        if(a!=-1)
        printf("%d %d\n",b,a);
        else
        printf("LOOP\n");
    }
}