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----------------------------------------------------------------------------------------------------------------------
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cctype>
#include <vector>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <bitset>
#include <map>
#include <algorithm>
#include <memory>
#include <sstream>
#include <functional>
#include <iostream>
#include <fstream>
#include <set>

//using namespace--------------------------------------------------------------------------------------------------------------
using namespace std;

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, s, n) for(int i = s; i < n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define FOREACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;

//const------------------------------------------------------------------------------------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//global-----------------------------------------------------------------------------------------------------------------------
char str[1000][1000];
bool test[1000][1000];
int ans_x, ans_y;
//function---------------------------------------------------------------------------------------------------------------------
bool solve(int x, int y){
	if (str[y][x] == '.'){
		ans_y = y + 1;
		ans_x = x + 1;
		return true;
	}
	if (test[y][x]){
		ans_x = INF;
		ans_y = INF;
		return true;
	}
	test[y][x] = true;
	if (str[y][x] == '>'){
		if (solve(x + 1, y))
			return true;
	}
	if (str[y][x] == '<'){
		if (solve(x - 1, y))
			return true;
	}
	if (str[y][x] == '^'){
		if (solve(x, y + 1))
			return true;
	}
	if (str[y][x] == 'v'){
		if (solve(x, y - 1))
			return true;
	}
}

int main(){
	char str[1000][1000];
	int a, b;
	while(true){
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0)
			return 0;
		rep(i, a)
			scanf("%s", str[i]);
		rep(i, a)
			rep(j, b)
			test[i][j] = false;
		if (solve(0, 0)){
			if (ans_y == INF && ans_x == INF)
				printf("LOOP\n");
			else
				printf("%d %d", ans_y, ans_x);
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
    int w,h;
    while(cin>>h>>w,h) 
    {
        string f[h];
        for(int i = 0; i < h; ++i)
        {
            cin>>f[i];
        }
 
        bool used[h][w];
        memset(used,0,sizeof(used));
 
        int x=0,y=0;
        while(1) 
        {
            if(used[y][x])
            {
                cout<<"LOOP"<<endl;
                break;
            }
            if(f[y][x]=='.')
            {
                cout<<x<<" "<<y<<endl;
                break;
            }
            used[y][x]=true;
 
            if(f[y][x]=='>') x+=1;
            if(f[y][x]=='<') x-=1;
            if(f[y][x]=='^') y-=1;
            if(f[y][x]=='v') y+=1;
        }
    }
  return 0;
}

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

int m,n,w,h;
char b[102][102];
bool v[102][102];

void dfs(int y,int x){
    if(v[y][x])
        cout<<"LOOP"<<endl;
    v[y][x]=1;
    if(b[y][x]=='>')
        dfs(y,x+1);
    if(b[y][x]=='v')
        dfs(y+1,x);
    if(b[y][x]=='<')
        dfs(y,x-1);
    if(b[y][x]=='^')
        dfs(y-1,x);
    cout<<x<<" "<<y<<endl;
}

int main(){
    while(cin>>h>>w,w||h){
        for(int i=0;i<h;i++)
            cin>>b[i];
        memset(v,0,sizeof(v));
        dfs(0,0);
    }
}

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

int main(){
	int w,h;
	while(cin>>w>>h )
	{
		if(h==0 || w==0)break;
		char mass[102][102];
		bool key[102][102];

		for( int i=0; i<102; i++) {
			for( int j=0; j<102; j++){
				key[i][j]=false;
			}
		}

		for( int i=0; i<h; i++) {
			for( int j=0; j<w; j++){
				cin>>mass[i][j];
				key[i][j]=false;
			}
		}
		w=0,h=0;
		while(1)
		{
			key[h][w]=true;
			if( mass[h][w] == '>' ) w++;
			else if( mass[h][w] == '<' ) w--;
			else if( mass[h][w] == '^' ) h--;
			else if( mass[h][w] == 'v' ) h++;
			else {
				cout<<w<<" "<<h<<endl;
				break;
			}
			
			if(key[h][w]) {
				puts("LOOP");
				break;
			}
		}
	}

	return 0;
}

C++: #include<stdio.h>
#include<string.h>

int main(){
  while(1){
    int h, w;
    scanf("%d %d", &h, &w);
    if(h==0 && w==0)
      break;
    else{
      char s[100][100];
      int i;
      for(i=0;i<h;i++){	
	scanf("%s", s[i]);
      }
      int x=0;
      int y=0;
      int xx[10000]={};
      int yy[10000]={};
      int j=0;
      while(1){
	xx[j]=x;
	yy[j]=y;
	j++;
	if(s[x][y] == '>')
	  y++;
	if(s[x][y] == '<')
	  y--;
	if(s[x][y] == '^')
	  x--;
	if(s[x][y] == 'v')
	  x++;	
	if(s[x][y] == '.')
	  {printf("%d %d\n", y, x);break;}
	
	int k;
	int flag=0;
	for(k=0;k<10000;k++){
	  if(xx[k]==x && yy[k]==y){flag++;}
	}
	if(flag!=0)
	  {printf("LOOP\n");break;}
      }
    }
  }
  return 0;
}

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

int main(){
   int a, b, i, j;
   char map[102][102]
   
   while(1){
      cin >> a >> b;
      if(a+b==0) break;
      
      for(i=0; i< a; i++){
         for(j=0; j< b; j++){
            cin >> map[i][j];
         }
      }
      i=0;j=0;
      while(1){
         if(map[i][j]=="."){
            cout << i << " " << j << endl;
         }else if(map[i][j]=="#"){
            cout << "loop" << endl;
         }else if(map[i][j]==">"){
            map[i][j]="#";
            j++;
         }else if(map[i][j]=="<"){
            map[i][j]="#";
            j--;
         }else if(map[i][j]=="^"){
            map[i][j]="#";
            i++;
         }else if(map[i][j]=="v"){
            map[i][j]="#";
            i--;
         }
      }
   }
   return 0;
   
   
}