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<string>
using namespace std;
int main(){
	int h,w;
	while(cin>>h>>w,w||h){
		char a[h][w];
		for(int i=0;i<w;i++){
			for(int j=0;j<h;j++){
				cin>>a[i][j];
			}
		}
		bool flag=true;
		int i=0,j=0;
		while(flag){
			flag=true;
			if(a[i][j]=='v'){
				i++;
				a[i][j]='!';
			}
			else if(a[i][j]=='>'){
				j++;
				a[i][j]='!';
			}
			else if(a[i][j]=='<'){
				j--;
				a[i][j]='!';
			}
			else if(a[i][j]=='^'){
				i--;
				a[i][j]='!';
			}
			else if(a[i][j]=='.'){
				break;
			}
			else if(a[i][j]=='!'){
				flag=false;
			}
		}
		if(!flag){
			cout<<"LOOP"<<endl;
		}
		else{
			cout<<j<<' '<<i<<endl;
		}
	}
}

C++: #include<iostream>
using namespace std;
int main() {
	int h, w; 
	while (cin >> h >> w) {
		if (!h && !w)return 0;
		char map[114][514];
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				cin >> map[i][j];
		int i = 0, j = 0;
		for (int p = 1; p <= 10000; p++) {
			if (map[i][j] == '.') {
				cout << j << ' ' << i << endl;
				continue;
			}
			else if (map[i][j] == '>') j++;
			else if (map[i][j] == '<') j--;
			else if (map[i][j] == '^') i--;
			else if (map[i][j] == 'v') i++;
		}
		cout << "LOOP\n";
	}
}

C++: #include<iostream>
using namespace std;
int main(){
  char mas[100][101];
  int h,w,i,j,t=0,loop=0;
  while(1){
  cin >> h >> w;
  if(h==0 && w==0){
    break;
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin >> mas[i][j];
    }
  }
  i=0;
  j=0;
  while(1){
    t++;
    if(t>10201){
      loop++;
      break;
    }
    if(mas[i][j]=='<'){
      j--;
    }
    else if(mas[i][j]=='^'){
      i--;
    }
    else if(mas[i][j]=='v'){
      i++;
    }
    else if(mas[i][j]=='>'){
      j++;
    }
    if(mas[i][j]=='.'){
      break;
    }
  }
  if(loop!=0){
    cout << "LOOP" << endl;
  }
  else{
  cout << j << " " << i << endl;
  }
  }
  return (0);
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

typedef pair<int, int> P;

int main() {
	int H, W;
	while (cin >> H >> W && H && W) {
		string *field = new string[H];
		for (int i = 0; i < H; i++)
			cin >> field[i];
		int x = 0, y = 0;
		vector<P> v;
		while (1) {
			v.push_back(make_pair(x, y));
			if (field[y][x] == '>')
				x++;
			if (field[y][x] == '<')
				x--;
			if (field[y][x] == '^')
				y--;
			if (field[y][x] == 'v')
				y++;
			if (field[y][x] == '.') {
				cout << x << " " << y << endl;
				break;
			}
			int loop = 0;
			vector<P>::iterator it = v.begin();
			while (it != v.end()) {
				if (it->first == x && it->second == y) {
					cout << "LOOP" << endl;
					loop = 1;
					break;
				}
				it++;
			}
			if (loop)
				break;
		}
		delete[] field;
	}
	return 0;
}

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

int main()
{
    int h, w;
    char m[100][100];
    bool b[100][100];

    while( cin >> h >> w )
    {
        if( h == 0 && w == 0 )
            break;

        for( int i = 0; i < h; i++ )
            for( int j = 0; j < w; j++ )
            {
                m[i][j] = '.';
                b[i][j] = false;
            }
        for( int i = 0; i < h; i++ )
            for( int j = 0; j < w; j++ )
                cin >> m[i][j];

        int i = 0, j = 0;
        while( m[i][j] != '.' && b[i][j] != true )
        {
            b[i][j] = true;
            if( m[i][j] == '>' )
                j++;
            else if( m[i][j] == '<' )
                j--;
            else if( m[i][j] == '^' )
                i--;
            else if( m[i][j] == 'v' )
                i++;
            else;
        }
        if( b[i][j] == false )
            cout << j << " " << i << endl;
        else
            cout << "LOOP" << endl;
    }    

    return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#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 all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	char c[110][110] = {};
	int cnt[110][110] = {};
	for (int H, W; cin >> H >> W&&H;) {
		memset(cnt, 0, sizeof(cnt));
		rep(i, 0, H)rep(j, 0, W)cin >> c[i][j];
		int i = 0, j = 0;
		while (true) {
			cnt[i][j]++;
			if (cnt[i][j] > 10) {
				cout << "LOOP" << endl;
				break;
			}
			else {
				bool flag = false;
				switch (c[i][j])
				{
				case '.':
					cout << j << " " << i << endl;
					flag = true;
					break;
				case '>':
					j++;
					break;
				case '<':
					j--;
					break;
				case '^':
					i--;
					break;
				case 'v':
					i++;
					break;
				default:
					break;
				}
				if (flag)break;
			}
		}
	}
	return 0;
}

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


int walk(int, int);
char f[100][100];
int H, W;

int main(void){
	while (cin >> H >> W, (H || W)){
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> f[i][j];
			}
		}
		walk(0, 0);
	}
}

int walk(int y, int x){
	switch (f[x][y]){
	case '.':
		printf("%d %d\n", y, x);
		break;
	case 'v':
		f[x][y]= 'a';
		walk(y, x+1);
		break;
	case '^':
		f[x][y] = 'a';
		walk(y, x-1);
		break;
	case '>':
		f[x][y] = 'a';
		walk(y+1, x);
		break;
	case '<':
		f[x][y] = 'a';
		walk(y-1, x);
		break;
	case 'a':
		printf("LOOP\n");
		break;

	}

	return 0;
}