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>
using namespace std;

enum Tile{
    RIGHT, LEFT, UP,DOWN, FINISH,UNKOEN
};

void MagicTile(int width, int height){
    int x=0,y=0,i=0,j=0;
    string string;
    Tile t;
    Tile *map = new Tile[width * height];
    
    for(i=0;i<height;i++){
        cin >> string;
        cout <<string <<endl;
        for(j=0;j<width;j++){
            switch (string[j]){
                case '>': t = RIGHT;break;
                case '<': t = LEFT;break;
                case '^': t = UP;break;
                case 'v': t = DOWN;break;
                case '.': t = FINISH;break;
                //default: t = UNKOEN;
            }
            map[j+i*width] = t;
        }
        
    }
    int count=0,total=width*height;
    while(map[x+y*width]!=FINISH){
        switch (map[x+y*width]){
            case RIGHT: x++;break;
            case LEFT: x--;break;
            case UP: y--;break;
            case DOWN: y++;break;
            case FINISH: break;
        }
        count++;
        if(total<=count) break;
    }
    if(count==total){
        cout <<"LOOP"<<endl;
    }
    else {
        cout << x <<" "<< y << endl;
    }
}


int main(){
    int m,n;
    cin >> m >> n;
    cin.ignore();
    while(!(m==0 && n==0)){
        MagicTile(n,m);
        cin >> m >> n;
    }
    return 0;
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
char imap[101][101];
int d[101][101];
int h, w;

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


int main()  {

    for (; ;) {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; i++) {
            fill(d[i], d[i]+w, -1);
            scanf("%s", imap[i]);
        }
        dfs(0, 0, 0);
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    char d[101][101],ch;
    int w,h,i,j;
    while(cin>>h>>w,h){
        for(i=0;i<h;i++)for(j=0;j<w;j++)cin>>d[i][j];
        i=j=0;
        while(d[i][j]!='.'&&d[i][j]!='X'){
            ch=d[i][j];
            d[i][j]='X';
            switch (ch){
                case '>':j++;break;
                case '<':j--;break;
                case 'v':i++;break;
                case '^':i--;break;
            }
        }
        (d[i][j]=='.')?(cout<<j<<" "<<i<<endl):(cout<<"LOOP"<<endl);
    }

}

C++: #include<iostream>
#include <vector>

using namespace std;

int main(void) {
	vector<string> map;
	string tmp;
	int w, h;
	int i;

	while(true) {
		cin >> h >> w;
		if(w == 0 && h == 0) { break; }
		map.clear();
		for(i = 0; i < h; i++) {
			cin >> tmp;
			map.push_back( tmp );
		}
		w = 0;
		h = 0;
		while(true) {
			if(map[h][w] == '>') {
				map[h][w] = '*';
				w++;
			} else if(map[h][w] == 'v') {
				map[h][w] = '*';
				h++;
			} else if(map[h][w] == '<') {
				map[h][w] = '*';
				w--;
			} else if(map[h][w] == '^') {
				map[h][w] = '*';
				h--;
			} else if(map[h][w] == '.') {
				cout << w << " " << h << endl;
				break;
			} else {
				cout << "LOOP" << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int h,w;
	while(cin>>h>>w,w||h){
		char a[h][w];
		for(int i=0;i<w;i++){
			for(int j=0;j<h;j++){
				cin>>a[i][j];
			}
		}
		bool flag=true;
		int i=0,j=0;
		while(flag){
			flag=true;
			if(a[i][j]=='v'){
				i++;
				a[i][j]='!';
			}
			if(a[i][j]=='>'){
				j++;
				a[i][j]='!';
			}
			if(a[i][j]=='<'){
				j--;
				a[i][j]='!';
			}
			if(a[i][j]=='^'){
				i--;
				a[i][j]='!';
			}
			if(a[i][j]=='.'){
				break;
			}
			if(a[i][j]=='!'){
				flag=false;
			}
		}
		if(!flag){
			cout<<"LOOP"<<endl;
		}
		else{
			cout<<j<<' '<<i<<endl;
		}
	}
}

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

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

int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h+w==0) break;
		char a[w][h];
		bool p[w][h];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> a[j][i];
				p[j][i] = false;
			}
		}
		int x = 0;
		int y = 0;
		bool loop = false;
		while(1){
			if(p[x][y]){ loop = true; break;}
			p[x][y] = true;
			if(a[x][y]=='.') break;
			else if(a[x][y]=='>') x++;
			else if(a[x][y]=='<') x--;
			else if(a[x][y]=='^') y--;
			else if(a[x][y]=='v') y++;
		}
		if(loop) cout << "LOOP" << endl;
		else cout << x << " " << y << endl;
	}
}

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

int h,w;
char maps[150][150];
int check[150][150];
int x=0,y=0;

int tansaku();

int main(){
  while(1){
  cin>>h>>w;
  if(!(h||w))break;
 
  //init
  memset(check,0,sizeof(check));

  //input
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>maps[i][j];
    }
  }
  if(tansaku())cout<<"LOOP"<<endl;
  else cout<<x<<" "<<y<<endl;
  }
}

int tansaku(){
  x=0;y=0;
  check[0][0]++;
  while(maps[y][x]!='.'){
    if(maps[y][x]=='>')x++;
    else if(maps[y][x]=='<')x--;
    else if(maps[y][x]=='v')y++;
    else if(maps[y][x]=='^')y--;
    check[y][x]++;
    if(check[y][x]>=2){
      return 1;
    }
  }
  return 0;
}