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 <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>

int main() {
  int w, h;
  while(cin >>h >>w && w){
    vector<string> v(h);
    REP(i, h) cin >>v[i];
    vector< vector<bool> > visited(h, vector<bool>(w, false));
    int ny = 0, nx = 0;
    while(v[ny][nx] != '.' && !visited[ny][nx]){
      visited[ny][nx] = true;
      if(v[ny][nx] == '>') ++nx;
      if(v[ny][nx] == '<') --nx;
      if(v[ny][nx] == 'v') ++ny;
      if(v[ny][nx] == '^') --ny;
    }
    if(!visited[ny][nx]) cout <<nx <<" " <<ny <<endl;
    else cout <<"LOOP" <<endl;
  }
  return 0;
}

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

char c[101][101] = { 0 };
int x, y;

void move_tile() {
	if (c[y][x] == '^') {
		c[y][x] = 'l';
		y = y - 1;
		move_tile();
	}
	else if (c[y][x] == 'v') {
		c[y][x] = 'l';
		y = y + 1;
		move_tile();
	}
	else if (c[y][x] == '<') {
		c[y][x] = 'l';
		x = x - 1;
		move_tile();
	}
	else if (c[y][x] == '>') {
		c[y][x] = 'l';
		x = x + 1;
		move_tile();
	}
	else {
		return;
	}

}

int main(void) {
	while (1) {
		int h, w;
		cin >> h >> w;
		if (h == 0)return 0;
		for (int i = 0; i <h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> c[i][j];
			}
		}

		x = y = 0;
		move_tile();

		if (c[y][x] == 'l') {
			cout << "LOOP" << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}

}

C++: #include <cstdio>

#define MAX (105)

void search(int x, int y);

int h, w;
char data[MAX][MAX];
char flag[MAX][MAX];

int main(void)
{
    int i, j;
    
    while (1){
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) break;
        for (i = 0; i < MAX; i++){
            for (j = 0; j < MAX; j++){
                data[i][j] = '\0';
                flag[i][j] = '0';
            }
        }
        for (i = 0; i < h; i++){
            scanf("%s", data[i]);
        }
        search(0, 0);
    }
    
    return (0);
}

void search(int x, int y)
{
    if (flag[x][y] == '1'){
        printf("LOOP\n");
        return;
    }
    if (data[x][y] == '.'){
        printf("%d %d\n", y, x);
        return;
    }
    if (data[x][y] == '>'){
        flag[x][y] = '1';
        search(x, y + 1);
    }
    else if (data[x][y] == '<'){
        flag[x][y] = '1';
        search(x, y - 1);
    }
    else if (data[x][y] == '^'){
        flag[x][y] = '1';
        search(x - 1, y);
    }
    else if (data[x][y] == 'v'){
        flag[x][y] = '1';
        search(x + 1, y);
    }
    
}

C++: #include<iostream>

using namespace std;
int H, W;
int x = 0, y = 0;
int rog[100][100];
bool check(){
	if (rog[x][y] == 0){
		cout << "LOOP" << endl;
		return true;
	}
	else{
		return false;
	}
}
int main(){
	char map[100][100];

	while (cin >> H >> W,W+H){

		int x = 0, y = 0;
		map[100][100] = {};
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> map[j][i];
				rog[j][i] = 1;
			}
		}
		while (1){
			if (map[x][y] == '>'){
				x++;
				if (check() == true){ break; }
			}
			else if(map[x][y]=='v'){
				y--;
				if (check() == true){ break; }
			}
			else if (map[x][y] == '<'){
				x--;
				if (check() == true){ break; }
			}
			else if (map[x][y] == '^'){
				y++;
				if (check() == true){ break; }
			}
			else {
				cout << x << " " << y << endl;
				break;
			}
			
			rog[x][y] = 0;

		}
	}
	return 0;
}

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[11][11];

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<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];
   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(map[x][y]=='>') 
       {
         x++;
         step++;
         cout<<">"<<" ";                      
       }        
       if(map[x][y]=='<')
       {
         x--;
         step++;   
         cout<<"<"<<" ";                   
       }
       if(map[x][y]=='v')
       {
         y++;
         step++;         
         cout<<"v"<<" ";             
       }
       if(map[x][y]=='^')
       {
         y--;
         step++;         
         cout<<"^"<<" ";             
       }
       if(step>(w*h))
       {
         flag=true;
         break;            
       }
       if(map[x][y]=='.')
       {
         break;                  
       }
     }        
     if(flag) cout<<"LOOP"<<endl;
     else cout<<x<<" "<<y<<endl;
   }
   //while(1);
   return 0;
 }