Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		l := strings.Split(stdin.Text(), " ")
		if l[0] == "0" {
			break
		}
		h, _ := strconv.Atoi(l[0])
		w, _ := strconv.Atoi(l[1])

		tile := make([][]rune, h)
		done := make([][]bool, h)
		for i := 0; i < h; i++ {
			stdin.Scan()
			s := stdin.Text()
			tile[i] = make([]rune, w)
			done[i] = make([]bool, w)
			for j, c := range s {
				tile[i][j] = c
			}
		}
		i, j := 0, 0
		for tile[i][j] != '.' {
			if done[i][j] {
				i = -1
				break
			}
			done[i][j] = true
			switch tile[i][j] {
			case '>':
				j++
			case '<':
				j--
			case '^':
				i--
			case 'v':
				i++
			}
		}
		if i < 0 {
			fmt.Println("LOOP")
		} else {
			fmt.Println(j, i)
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
int main( void )
{
	while ( 1 )
	{
		int w, h;
		cin >> w >> h;
		if ( w == 0 && h == 0 )
			break;

		vector <string> data;
		for ( int i = 0; i < h; i++ )
		{
			string line;
			cin >> line;
			data.push_back( line );
		}

		bool loop_flag = false;
		int x = 0;
		int y = 0;
		while ( 1 )
		{
			int oldx = x;
			int oldy = y;
			if ( data[y][x] == '.' )
				break;
			else if ( data[y][x] == '>' )
				x++;
			else if ( data[y][x] == 'v' )
				y++;
			else if ( data[y][x] == '^' )
				y--;
			else if ( data[y][x] == '<' )
				x--;
			else if ( data[y][x] == 'x' )
			{
				loop_flag = true;
				break;
			}
			data[oldy][oldx] = 'x';
		}

		if ( loop_flag )
			cout << "LOOP" << endl;
		else
			cout << x << " " << y << endl;

	}
	return 0;
}

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;
}