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++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
vector<string>v;
set<pair<int, int>>S;
pair<int, int> simulate(int x, int y) {
	auto it = S.find(make_pair(x, y));
	if (it != S.end())return make_pair(-1, -1);
	else S.insert(make_pair(x, y));

	if (v[x][y] == '>')return simulate(x, y + 1);
	else if (v[x][y] == '<')return simulate(x, y - 1);
	else if (v[x][y] == '^')return simulate(x - 1, y);
	else if (v[x][y] == 'v')return simulate(x + 1, y);
	else return make_pair(x, y);
}
signed main() {
	int w, h;
	while (cin >> h >> w, h || w) {
		v = vector<string>(h);
		S.clear();
		rep(i, 0, h) cin >> v[i];

		auto p = simulate(0, 0);
		if (p == make_pair(-1, -1)) {
			cout << "LOOP" << endl;
		}
		else cout << p.second << " " << p.first << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
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 dx, dy;
int main()
{
  int h, w;

  while (cin >> h >> w, h + w){
    string tile[h];
    bool done[h][w], 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>
#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;
		}
		if(n*m > 2){
			array1 = (int *)calloc(n*m, sizeof(int));
			array2 = (int *)calloc(n*m, sizeof(int));
		} else {
			array1 = (int *)calloc(2, sizeof(int));
			array2 = (int *)calloc(2, sizeof(int));
		}
		
		for(i = 0; i < n; i++){
			for(j = 0, tmp = i*m; j < m; j++){
				cin >> w;
				if(tmp < 0){
				break;
				}
				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;
				}
			}
			if(tmp < 0){
				break;
			}
		}
		if(tmp < 0){
			cout << "LOOP" << endl;
			free(array1);
			free(array2);
			continue;
		}
		
		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 <iostream>
#include <cstdio>
using namespace std;

int main(void) {
  char G[101][101];
  bool visited[101][101];
  int W, H;
  string str;
  
  while(cin >> W >> H) {
    if(W==0 && H==0) break;
    for(int i=0; i<H; i++) {
      cin >> str;
      for(int j=0; j<W; j++) {
	G[i][j] = str[j];
	visited[i][j] = false;
      }
    }
    
    int x=0, y=0;
    while(1) {
      if(visited[y][x]) { cout << "LOOP" << endl; break; }
      
      visited[y][x] = true;
      if(G[y][x] == '>') x++;
      else if(G[y][x] == 'v') y++;
      else if(G[y][x] == '^') y--;
      else if(G[y][x] == '<') x--;
      else if(G[y][x] == '.') { cout << x << " " << y << endl; break; }
    }

  }
  
  return 0;
}

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

int main(){
  int h,w;
  while(cin>>h>>w,h||w){
    int x=0,y=0;
    vector<string> map(h);
    for(auto &str:map)
      cin>>str;
    while(x!=-1){
      char tile=map[y][x];
      map[y][x]='=';
      switch(tile){
        case '>':
          x++;
          break; 
        case '<':
          x--;
          break;  
        case '^':
          y--;
          break;
        case 'v':
          y++;
          break;
        case '.':
          cout<<x<<' '<<y<<endl;
          x=-1;
          break;
        case '=':
          cout<<"LOOP"<<endl;
          x=-1;
          break;
      }

    }
  }

}

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

using namespace std;
char map[100][100];
int H, W;
int x = 0, y = 0;
bool check(){
	if (map[x][y] == 0){
		cout << "LOOP" << endl;
		return true;
	}
	else{
		return false;
	}
}
int main(){
	
	while (1){

		int x = 0, y = 0;
		map[100][100] = {};
		cin >> H >> W;

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

		}
	}
	return 0;
}

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

int main(){
    int w,h;
    int ichi[101][101]={0};
    while(1){
        int i=0,j=0;
        cin >> w >> h;
        if(w == 0 && h == 0){
            break;
        }
        char map[w][h];
        for(int n=0;n<w;n++){
            for(int k=0;k<h;k++){
                cin >> map[n][k];
            }
        }
        while(1){
            for(int n=0;n<w;n++){
                memset(ichi[n],0,sizeof(ichi[i]));
            }
            if(ichi[i][j] == 1){
                cout << "LOOP" << endl;
                break;
            }
            else if(map[i][j] == '.'){
                cout << j << " " << i << endl;
                break;
            }
            if(map[i][j] == '>'){
                ichi[i][j] = 1;
                j++;
            }
            else if(map[i][j] == '<'){
                ichi[i][j] = 1;
                j--;
            }
            else if(map[i][j] == '^'){
                ichi[i][j] = 1;
                i--;
            }
            else if(map[i][j] == 'v'){
                ichi[i][j] = 1;
                i++;
            }
        }
    }
}