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<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;
   char map[100+5][100+5];
   while(cin>>h>>w&&(w||h))
   {
     bool flag=false;
     int map2[100+5][100+5]={{0}};
     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]=='>') 
       {
         map2[x][y]=1;
         y++;
         step++;
         //cout<<">"<<" ";                      
       }        
       if(map[x][y]=='<')
       {
         map2[x][y]=1;
         y--;
         step++;   
         //cout<<"<"<<" ";                   
       }
       if(map[x][y]=='v')
       {
         map2[x][y]=1;
         x++;
         step++;         
         //cout<<"v"<<" ";             
       }
       if(map[x][y]=='^')
       {
         map2[x][y]=1;
         x--;
         step++;         
         //cout<<"^"<<" ";             
       }
       if(map[x][y]=='.')
       {
         break;                  
       }
       if(flag) break;
     }        
     if(flag) cout<<"LOOP"<<endl;
     else cout<<y<<" "<<x<<endl;
   }
   //while(1);
   return 0;
 }

C++: #include <stdio.h>

int main(void){	
	int x, y;
	int w, h;
	int loop;
	char tile[101][101];


	while(1){
		x = 0;
		y = 0;
		loop = 0;

		scanf("%d %d", &w, &h);
		if(w == 0 && h == 0) break;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				scanf(" %1c", &tile[j][i]);
			}
		}

		while(1){
			char c = tile[x][y];
			tile[x][y] = 'x';

			if(c == '>') x++;
			else if(c == '<') x--;
			else if(c == '^') y--;
			else if(c == 'v') y++;
			else if(c == '.') break;
			else{
				loop = 1;
				break;
			}
		}
		if(loop == 0)printf("%d %d\n", x, y);
		else printf("LOOP\n");
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int w,h;
	int dx[128]={0};
	int dy[128]={0};
	dx['<'] = -1;
	dx['>'] = 1;
	dy['^'] = -1;
	dy['v'] = 1;
	while(cin >> w >> h , w){
		char data[128][128];
		rep(i,h)rep(j,w)cin >> data[i][j];
		int x = 0 , y = 0 , f = 0;
		while(data[y][x]!='.'){
			char c = data[y][x];
			if(c == '-'){f = 1 ; break;}
			else data[y][x] = '-';
			x += dx[c] , y += dy[c];
		}
		if(f)cout << "LOOP" << endl;
		else cout << x << " " << y << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int a, b;

int main() {
	while (cin >> a >> b) {
		if (a == 0 && b == 0) {
			break;
		}
		char data[102][102];
		int b[a][b] = { 0 };
	      for(int i=0; i< a; i++){
	         for(int j=0; j< b; j++){
	            cin >> data[i][j];
	         }
	      }

		int H = 0, W = 0;
		int loop = 0;
		while (1) {
			if (data[H][W] == '<') {
				b[H][W] = 1;
				W -= 1;
				if (b[H][W] == 1) {
					loop = 1;
					break;
				}

			} else if (data[H][W] == '>') {
				b[H][W] = 1;
				W += 1;
				if (b[H][W] == 1) {
					loop = 1;
					break;
				}
			} else if (data[H][W] == 'v') {
				b[H][W] = 1;
				H += 1;
				if (b[H][W] == 1) {
					loop = 1;
					break;
				}
			} else if (data[H][W] == '^') {
				b[H][W] = 1;
				H -= 1;
				if (b[H][W] == 1) {
					loop = 1;
					break;
				}
			} else {
				break;
			}
		}
		if (loop != 1) {
			printf("%d %d\n", W, H);
		} else {
			printf("LOOP\n");
		}
	}
	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 << x << ' ' << y << 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);
		cin >> tile[a];
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int loop_counter[100][100]={0};
string board[100];
int loop(int y,int x ){
	loop_counter[y][x]++;
	if(loop_counter[y][x]>=2)
		cout<<"LOOP"<<endl;
	else if(board[y][x]=='^')
		return loop(y-1,x);
	else if(board[y][x]=='v')
		return loop(y+1,x);
	else if(board[y][x]=='<')
		return loop(y,x-1);
	else if(board[y][x]=='>')
		return loop(y,x+1);
	else if(board[y][x]=='.')
		cout << x <<" "<<y<<endl;
	return 0;
}
int main(){
	int h,w;
	while(cin >> h >> w){
		if(h==0 && w==0)
			return 0;
		for(int i=0 ; i<h ; i++ )
			cin >> board[i];
		loop(0,0);
	}
}

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(1){
      switch(c[t_y][t_x]){
      case '>':
        t_x++;
        break;
      case '<':
        t_x--;
        break;
      case 'v':
        t_y++;
        break;
      case '^':
        t_y--;
        break;
      }
      if(c[t_y][t_x]=='.'){
        std::cout<<t_x<<" "<<t_y<<std::endl;
        break;
      }
      if(r[t_y][t_x]){std::cout<<"LOOP"<<std::endl;break;}
      r[t_y][t_x]=1;
    }
  }
}