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

int main(){
    int w,h;
    int ichi[101][101]={0};
    while(1){
        int i=0,j=0;
        cin >> w >> h;
        if(w == 0 && h == 0){
            break;
        }
        char map[w][h];
        for(int n=0;n<w;n++){
            for(int k=0;k<h;k++){
                cin >> map[n][k];
            }
        }
        for(int n=0;n<w;n++){
            memset(ichi[n],0,sizeof(ichi[i]));
        }
        while(1){
            if(ichi[i][j] == 1){
                cout << "LOOP" << endl;
                break;
            }
            else if(map[i][j] == '.'){
                cout << j << " " << i << endl;
                break;
            }
            if(map[i][j] == '>'){
                ichi[i][j] = 1;
                j++;
            }
            else if(map[i][j] == '<'){
                ichi[i][j] = 1;
                j--;
            }
            else if(map[i][j] == '^'){
                ichi[i][j] = 1;
                i--;
            }
            else if(map[i][j] == 'v'){
                ichi[i][j] = 1;
                i++;
            }
        }
    }
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

int main()
{
  int h, w;

  while (cin >> h >> w, h + w){
  	int dx = 0, dy = 0;
    string tile[101];
    bool done[101][101], flag = false;

    REP(i, h){
      REP(j, w) done[i][j] = false;
    }
    REP(i, h) cin >> tile[i];
    while (tile[dy][dx] != '.'){
      if (done[dy][dx]){
        flag = true;
        cout << "LOOP" << endl;
        break;
      }
      done[dy][dx] = true;
      if (tile[dy][dx] == '<') dx--;
      if (tile[dy][dx] == '>') dx++;
      if (tile[dy][dx] == '^') dy--;
      if (tile[dy][dx] == 'v') dy++;
    }
    if (flag) continue;
    cout << dx << " " << dy << endl;
  }
}

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 <iostream>
using namespace std;
int main()
{
	int w, h, i, j, c, x, y;
	char f[100][100];
	bool b;
	while (cin >> w >> h)
	{
		if (w == 0 && h == 0) break;
		x = y = 0;
		b = false;
		c = 0;
		for (i = 0; i < w; i++)
			for (j = 0; j < h; j++)
				cin >> f[i][j];
		while (c <= w*h)
		{
			switch (f[y][x])
			{
			case '>':
				x++;
				break;
			case '^':
				y--;
				break;
			case '<':
				x--;
				break;
			case 'v':
				y++;
				break;
			default:
				cout << x << " " << y << endl;
				b = true;
				break;
			}
			if (b) break;
			c++;
		}
		if (!b) cout << "LOOP" << endl;
	}
}

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

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	int r, c;
	while(cin >> r >> c && (r || c)) {
		char board[110][110];
		bool b[110][110];
		rep(i,r) {
			rep(j,c) {
				b[i][j] = 0;
			}
		}

		rep(i,r) {
			string s;
			cin >> s;
			rep(j,c) {
				board[i][j] = s[j];
			}
		}
		
		char ch = board[0][0];
		int y = 0, x = 0;
		while(ch != '.' && !b[y][x]) {
			b[y][x] = 1;
			switch(ch) {
			case '>' : 
				x++;
				break;
			case '<' :
				x--;
				break;
			case '^' :   
				y--;
				break;
			case 'v' : 
				y++;
				break;
			default :
				break;
			}
			ch = board[y][x];
		}
		if(b[y][x]) cout << "LOOP" << endl;
		else cout << x << " " << y << endl;
	}
	return 0;
}

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

using namespace std;

int main(){

	int w,h;
	while(cin>>w>>h&&!(w==0&&h==0)){
		vector<string> field;
		string str;
		for(int i = 0; i < h; i++){
			cin>>str;
			field.push_back(str);
		}
		bool isPassed[200][200];
		memset(isPassed,0,sizeof(isPassed));
		int sy,sx;
		sy=sx=0;
		bool f=true;
		while(1){
			if(isPassed[sy][sx]){
				f=false;
				break;
			}
			isPassed[sy][sx]=true;
			if(field[sy][sx]=='>'){
				sx++;
			}
			else if(field[sy][sx]=='<'){
				sx--;
			}
			else if(field[sy][sx]=='v'){
				sy++;
			}
			else if(field[sy][sx]=='^'){
				sy--;
			}
			else
				break;
		}
		if(!f){
			cout<<"LOOP"<<endl;
		}
		else
			cout<<sx<<" "<<sy<<endl;
	}

	return 0;
}