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 <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int h, w;
	while (cin >> h >> w&&h != 0 && w != 0) {
		char maze[101][101];
		bool data[101][101] = { false };
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> maze[i][j];
			}
		}
		int posh = 0, posw = 0;
		bool isloop = false;
		while (maze[posh][posw] != '.') {
			if (data[posh][posw]) {
				isloop = true;
				break;
			}
			data[posh][posw] = true;
			if (maze[posh][posw] == '>')posw++;
			else if (maze[posh][posw] == '<')posw--;
			else if (maze[posh][posw] == '^')posh--;
			else posh++;
		}
		if (isloop) {
			cout << "LOOP" << endl;
		}
		else {
			cout << posw << " " << posh << endl;
		}
	}
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int h, w;
    while(cin >> h >> w, h){
        vector<string> v(h);
        for (int i = 0; i < h; ++i) cin >> v[i];
        vector<vector<int>> visited(h, vector<int>(w, 0));
        [&](){
            int a = 0, b = 0;
            while(true){
                if(visited[a][b]){
                    puts("LOOP");
                    return;
                }
                visited[a][b] = 1;
                if(v[a][b] == '>') b++;
                else if(v[a][b] == '^') a--;
                else if(v[a][b] == '<') b--;
                else if(v[a][b] == 'v') a++;
                else break;
            }
            printf("%d %d\n", b, a);
        }();
    }
    return 0;
}

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

int h, w;
char t[110][110];

int main(){
  while(cin >> h >> w, h || w){
    for(int i = 0; i < h; i++){
      cin >> t[i];
    }

    int x = 0, y = 0;

    while(true){
      //ツ止ツづ慊づ?つスツづィ, ツδ?ツプツつオツつスツづィツつオツつスツづァツ終ツ猟ケ
      if(t[y][x] == '.' || t[y][x] == 'L'){
        break;
      }

      //ツパツネツδ仰づ個津環づィツづ可暗堋督ョツつキツづゥ
      int nx = x;
      int ny = y;

      switch(t[y][x]){
        case '^': ny--; break;
        case '>': nx++; break;
        case 'v': ny++; break;
        case '<': nx--; break;
      }

      //ツ辿ツづ?つスツづ?つアツづォツづ可づ? ツ暗ウツづーツづつつッツづ?つィツつ「ツづ? ツδ?ツプツつオツつスツつアツづ?つェツづュツつゥツづゥツづヲツつ、ツづ可つキツづゥ
      t[y][x] = 'L';
      x = nx;
      y = ny;
    }

    //ツ暗ェツ度ツ辿ツづ?つスツつアツづ?つ?づゥツ渉ーツづ?終ツ猟ケツつオツづ?つ「ツつスツづァツδ?ツプ
    if(t[y][x] == 'L'){
      cout << "LOOP\n";
    }
    //'.'ツづ?終ツづュツづ?づ?つ「ツつスツづァツ止ツづ慊づ?つス
    else{
      cout << x << " " << y << endl;
    }
  }
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int W,H;
char fie[102][102];
int cost[102][102];
char df[]={'>','v','<','^'};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
  while(1){
    cin >> W >> H;
    memset(fie,-1,sizeof(fie));
    memset(cost,0,sizeof(cost));
    if(W==0 && H==0) break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> fie[j][i];
      }
    }
    int x=0,y=0;
    bool f=false;
    cost[x][y]=1;
    while(fie[x][y]!='.'){
      for(int i=0;i<4;i++){
	
	if(fie[x][y]==df[i]){
	  x+=dx[i];
	  y+=dy[i];
	}
      }
      if(cost[x][y]){
	f=true;
	break;
      }
      cost[x][y]=1;
    }
    if(!f) printf("%d %d\n",x,y);
    else puts("LOOP");
  }
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int w,h;
   bool flag=false;
   char map[100+5][100+5];
   int map2[100+5][100+5]={{0}};
   while(cin>>w>>h&&(w||h))
   {
     for(int i=0;i<h;i++)
     {
       for(int j=0;j<w;j++)
       {
         cin>>map[i][j];        
       }        
     }               
     int step=0;
     int x=0;
     int y=0;
     while(1)
     {
       if(map2[x][y]==1) 
       {
         flag=true;
         break;                  
       }
       if(map[x][y]=='>') 
       {
         x++;
         step++;
         map2[x][y]=1;
         //cout<<">"<<" ";                      
       }        
       if(map[x][y]=='<')
       {
         x--;
         step++;   
         map2[x][y]=1;
         //cout<<"<"<<" ";                   
       }
       if(map[x][y]=='v')
       {
         y++;
         step++;         
         map2[x][y]=1;
         //cout<<"v"<<" ";             
       }
       if(map[x][y]=='^')
       {
         y--;
         step++;      
         map2[x][y]=1;   
         //cout<<"^"<<" ";             
       }
       if(step>(w*h))
       {
         flag=true;
         break;            
       }
       if(map[x][y]=='.')
       {
         break;                  
       }
       if(flag) break;
     }        
     if(flag) cout<<"LOOP"<<endl;
     else cout<<x<<" "<<y<<endl;
   }
   //while(1);
   return 0;
 }

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int h,w;
  while(cin>>h>>w,h+w) {
    char ba[h][w];
    REP(y,h) {
      REP(x,w) {
        cin >> ba[x][y];
      }
    }
    int x = 0, y = 0;
    int dx[] = {0,1,0,-1};
    int dy[] = {-1,0,1,0};
    char aa[] = {'^','>','v','<'};
    map<char,int> hoge;
    REP(i,4)
      hoge[aa[i]] = i;
    int f[w][h];
    memset(f,0,sizeof(f));
    while(true) {
      if (f[x][y]) break;
      else f[x][y] = 0;
      if (ba[x][y] == '.') break;
      else {
        x += dx[hoge[ba[x][y]]];
        y += dy[hoge[ba[x][y]]];
      }
    }
    if (f[x][y]) cout << "LOOP" << endl;
    else cout << x << " " << y << endl;
  }
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int W,H;
char fie[102][102];
int cost[102][102];
char df[]={'>','v','<','^'};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
  while(1){
    cin >> W >> H;
    if(W==0 && H==0) break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> fie[j][i];
      }
    }
    int x=0,y=0;
    bool f=false;
    cost[x][y]=1;
    while(fie[x][y]!='.'){
      for(int i=0;i<4;i++){
	if(fie[x][y]==df[i]){
	  x+=dx[i];
	  y+=dy[i];
	}
      }
      if(cost[x][y]){
	f=true;
	break;
      }
      cost[x][y]=1;
    }
    if(!f) printf("%d %d\n",x,y);
    else puts("LOOP");
  }
}