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 <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime> 

using namespace std;

char tile[101][101];

void loop(int x,int y){
	if(tile[x][y]=='.'){
		cout << y << ' ' << x << endl;
		return;
	}
	if(tile[x][y]=='#'){
		cout << "LOOP" << endl;
		return;
	}
	if(tile[x][y]=='>'){
		tile[x][y]='#';
		loop(x,y+1);
	}
	if(tile[x][y]=='<'){
		tile[x][y]='#';
		loop(x,y-1);
	}
	if(tile[x][y]=='^'){
		tile[x][y]='#';
		loop(x-1,y);
	}
	if(tile[x][y]=='v'){
		tile[x][y]='#';
		loop(x+1,y);

	}
}

int main(void){
	int h,w;
	int x,y;
	int a;
	while(1){
		x=0,y=0;
		cin >> h >> w;
		if(h==0 && w==0)break;
		for(a=0;a<h;a++){
			cin >> tile[a];
		}
		loop(0,0);
	}
	return 0;
}

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

char board[100][100];
int boardf[100][100];


void search(int a,int b){
	if(boardf[a][b] == 1){
		cout << "LOOP" << endl;
		return ;
	}
	boardf[a][b] = 1;
	if(board[a][b] == '.'){
		cout << b << " " << a << endl;
		return;
	}
	if(board[a][b] == '>'){
		search(a,b+1);
	}else if(board[a][b] == '<'){
		search(a,b-1);
	}else if(board[a][b] == '^'){
		search(a-1,b);
	}else if(board[a][b] == 'v'){
		search(a+1,b);
	}
}

int main(){
	int a,b;
	char c;
	while(cin >> a >> b){
		if(a==0&&b==0){
			return 0;
		}
		
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				boardf[i][j] = 0;
			}
		}
		
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				cin >> c;
				board[i][j] = c;
			}
		}		
		
		search(0,0);

		/*for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				cout << board[i][j] << " ";
			}
			cout << endl;
		}*/		
	}
	return 0;
}

C++: #include <cstdio>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main() 
{
    int h,w;
    while (scanf("%d%d",&h,&w)) {
        if (h==0&&w==0) break;
        vector<string> map;
        for (int i=0; i<h; i++) {
            string in;
            cin>>in;
            map.push_back(in);
        }
        vector<vector<int> > went;
        for (int i=0; i<h; i++) {
            vector<int> num(w,0);
            went.push_back(num);
        }
        int ni=0, nj=0;
        bool flag=false;
        while (map[ni][nj]!='.') {
            if (went[ni][nj]==1) {
                flag=true;
                break;
            }
            went[ni][nj]++;
            if (map[ni][nj]=='>') {
                nj++;
            }
            else if (map[ni][nj]=='<') {
                nj--;
            }
            else if (map[ni][nj]=='^') {
                ni--;
            }
            else if (map[ni][nj]=='v') {
                ni++;
            }
        }
        if (flag) printf("LOOP\n");
        else printf("%d %d\n",ni,nj);
    }
}

C++: #include<iostream>
using namespace std;
int main(void)
{
  int h,w;
  while(true)
    {
      cin>>h>>w;
      if(h==0 && w==0)break;
      char str[h][w];
      int looper[h][w];
      for(int i=0;i<h;i++)
	{
	  for(int j=0;j<w;j++)
	    {
	      cin>>str[i][j];
	      looper[i][j]=0;
	    }
	}
      int i=0,j=0;
      
      while(true)
	{
	  if(str[i][j]=='>')
	    {
	      
	      j++;
	    }
	  else if(str[i][j]=='<')
	    {
	      j--;
	      
	    }
	  else if(str[i][j]=='v')
	    {
	      i++;
	    }
	  else 
	    {
	      i--;
	    }
	  
	  if(str[i][j]=='.')
	    {
	      cout<<j<<" "<<i<<endl;
	      break;
	    }
	  else if(looper[i][j]==1)
	    {
	      cout<<"LOOP"<<endl;
	      break;
	    }
	  
	  looper[i][j]++;
	}
 
    }
        return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

string data[500];
bool sumi[500][500];
int nx,ny,ox,oy,ansx,ansy,ox2,oy2;
int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h==0&&w==0) break;
		REP(i,h) cin >> data[i];
		REP(i,500) REP(j,500) sumi[i][j] = false;
		nx = 0; ny = 0; ox = 0; oy = 0;
		ox2 = 0; oy2 = 0;
		bool flg = true;

		sumi[nx][ny] = true;
		while(flg){
			if(data[nx][ny]=='>') ny++;
			if(data[nx][ny]=='<') ny--;
			if(data[nx][ny]=='^') nx--;
			if(data[nx][ny]=='v') nx++;
			if(data[nx][ny]=='.'){
				ansx = nx;
				ansy = ny;
				flg = false;
			}
			if(sumi[nx][ny]){
				ansx = -1;
				flg = false;
			}
			sumi[nx][ny] = true;
			ox = nx;
			oy = ny;
			ox2 = ox;
			oy2 = oy;
		}
		if(ansx==-1) cout << "LOOP" << endl;
		else cout << ansy << " " << ansx << endl;
	}
}

C++: #include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main(void){
  int h, w;

  while(cin >> h >> w){
	if((h|w) == 0) break;
	bool visited[h][w];
	bool isloop = false;
	char arrow[h][w];
	string str;
	for(int i=0;i<h;i++){
	  cin >> str;
	  for(int j=0;j<w;j++){
		arrow[i][j] = str[j];
	  }
	}
	
	int x=0,y=0;
	memset(visited, false, sizeof(visited));
	while(arrow[x][y] != '.'){
	  if(visited[x][y]){
		isloop = true;
		break;
	  }
	  visited[x][y] = true;
	  if(arrow[x][y] == '>'){
		y++;
	  }else if(arrow[x][y] == '^'){
		x--;
	  }else if(arrow[x][y] == 'v'){
		x++;
	  }else{
		y--;
	  }
	}
	if(isloop){
	  cout << "LOOP" << endl;
	}else{
	  cout << y << " " << x << endl;
	}
  }
}

C++: #include<stdio.h>
#include<string.h>
int main(void)
{
	int a,b,H,W,c[100][100]={0},d;
	scanf("%d %d",&H,&W);
	char map[100][101];
	for(d=0;d<H;d++)
		scanf("%s",map[d]);
	for(a=0,b=0;;)
	{
		c[a][b]++;
		if(c[a][b]==2)
		{
			printf("LOOP\n");
			break;
		}
		if(map[a][b]=='>')
			b++;
		else if(map[a][b]=='<')
			b--;
		else if(map[a][b]=='^')
			a--;
		else if(map[a][b]=='v')
			a++;
		else
		{
			printf("%d %d\n",a,b);
			break;
		}
	}	
}