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>

using namespace std;

int main(){
    int w,h;
    int i,j;
    while(1){
        cin >> w;
        cin >> h;
        if(w == 0 || h == 0) break;
        vector< vector<char> > v(101, vector<char>(101));
        for(j=0;j<h;++j){
            for(i=0;i<w;++i){
                cin >> v[i][j];
            }
        }
        int mi = 0, mj = 0;
        while(true){
            char c = v[mi][mj];
            v[mi][mj] = '#';
            if(c == '>') mi++;
            else if(c == '<') mi--;
            else if(c == '^') mj--;
            else if(c == 'v') mj++;
            else if(c == '#'){
                cout << "LOOP" << endl;
                break;
            } else if( c == '.' ){
                cout << mi << ' ' << mj << endl;
                break;
            }
        }
    }
    return 0;
}

C++: #include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	stringstream buff;
	while(n!=0 && m!=0){
		map<string,int> table;
		vector<string> args;
		for(int x=0;x<n;++x){
			string line;
			cin>>line;
			args.push_back(line);
		}
		int x=0,y=0;
		bool flag = true;
		while(args[x][y]!='.' && flag){
			stringstream buf;
			buf<<x<<":"<<y;
			if(table[buf.str()]){
				flag = false;
			}else{
					table[buf.str()]=100;
				switch(args[x][y]){
					case '>':
						++y;
						break;
					case '<':
							--y;
						break;
					case 'v':
						++x;
						break;
					case '^':
						--x;
						break;
						
				}
			}
		}
		if(flag)buff<<y<<" "<<x<<"\n";
		else	buff<<"LOOP\n";
		cin>>n>>m;
	}
	cout<<buff.str();
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint H, W;
	while (cin >> H >> W, H != 0) {
		vector<vector<char>>A(H, vector<char>(W));
		rep(i, H) {
			rep(j, W) {
				cin >> A[i][j];
			}
		}
		lint I = 0;
		lint J = 0;
		rep(i, 20000) {
			if (A[I][J] == '>') {
				J++;
			}
			else if (A[I][J] == '<') {
				J--;
			}
			else if (A[I][J] == '^') {
				I--;
			}
			else if (A[I][J] == 'v') {
				I++;
			}
			else if (A[I][J] == '.') {

			}
		}
		if (A[I][J] == '.') {
			cout << J << ' ' << I << endl;
		}
		else {
			cout << "LOOP" << endl;
		}
	}
}

C++: #include <iostream>

int main(){
  int a,b;
  while(std::cin>>a>>b){
    if(!a&&!b)return 0;
    char c[101][101];
    for(int y=0;y<a;y++){
      std::string s;
      std::cin>>s;
      for(int x=0;x<b;x++)
        c[y][x] = s[x];
    }
    int r[101][101]={0},t_x=0,t_y=0;
    while(c[t_y][t_x] != '.'){
      switch(c[t_y][t_x]){
      case '>':
        t_x++;
        break;
      case '<':
        t_x--;
        break;
      case 'v':
        t_y++;
        break;
      case '^':
        t_y--;
        break;
      }
      if(r[t_y][t_x]>1)break;
      r[t_y][t_x]++;
    }
    if(r[t_y][t_x]>1)std::cout<<"LOOP"<<std::endl;
    else{std::cout<<t_x<<","<<t_y;}
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <sstream>
#include <deque>

#define REP(i, n) for ( int i = 0; i < n; i++ )

using namespace std;

void dump(vector<string> f, int x = -1, int y = -1) {
    REP(i, f.size()) {
        REP(j, f[i].size()) {
            if ( i == y && j == x )
                cout << "#";
            else
                cout << f[i][j];
        }
        cout << endl;
    }
}

/*
0:上
1:右
2:下
3:左
*/
int mx[] = {0, 1, 0, -1},
    my[] = {-1, 0, 1, 0};

vector< vector<int> > closed;

void go(vector<string> &f, int x, int y) {
    // dump(f, x, y);
    // cout << endl;

    int mv;
    if ( closed[y][x] ) {
        cout << "LOOP" << endl;
        return;
    }
    closed[y][x] = 1;

    switch(f[y][x]) {
        case '.':
            cout << x << " " << y << endl;
            return;
        case '^':
            mv = 0;
            break;
        case '>':
            mv = 1;
            break;
        case 'v':
            mv = 2;
            break;
        case '<':
            mv = 3;
            break;
    }
    go(f, x+mx[mv], y+my[mv]);
}

int main() {
    int w, h;

    while( cin >> h >> w, w || h ) {
        vector<string> f(h);
        closed = vector< vector<int> >(h, vector<int>(w, 0));

        REP(i, h) {
            REP(j, w) {
                closed[i][j] = 0;
            }
        }

        REP(i, h) {
            cin >> f[i];
        }

        go(f, 0, 0);
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
string s[100];
bool used[100][100];
int h,w;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
main()
{
    while(cin>>h>>w,h)
    {
        for(int i=0;i<h;i++)
        {
            cin>>s[i];
            for(int j=0;j<w;j++)used[i][j]=0;
        }
        int x=0,y=0,f=0;
        while(!used[x][y])
        {
            used[x][y]=1;
            if(s[x][y]=='.')
            {
                f=1;
                cout<<x+1<<" "<<y+1<<endl;
                break;
            }
            int r=s[x][y]=='>'?0:s[x][y]=='<'?2:s[x][y]=='v'?1:3;
            x+=dx[r],y+=dy[r];
        }
        if(!f)cout<<"LOOP"<<endl;
    }
}