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 <string>

using namespace std;

string mp[100];
string dir = "^>v<";
const int dy[4] = {-1,0,1,0}, dx[4] = {0,1,0,-1};

char *rec(int y,int x){
	char tmp = mp[y][x];
	if(tmp == '.'){
		char ret[256];
		sprintf(ret,"%d %d",x,y);
		return ret;
	}else if(tmp == 't'){
		char ret[] = "LOOP";
		return ret;
	}
	mp[y][x] = 't';
	int d = dir.find(tmp);
	return rec(y + dy[d],x + dx[d]);
}


int main(void){
	int h, w;
	while(true){
		cin >> h >> w;
		cin.get();
		if(h == 0 && w == 0){
			break;
		}
		for(int i = 0;i < h;i++){
			getline(cin,mp[i]);
		}
		cout << rec(0,0) << endl;
	}
	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>>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>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<vector>
#include<cstdio>
#include<climits>
#include<cfloat>
#include<cstring>
#define foreach(t,p) for(t::iterator it=p.begin();it!=p.end();++it)
#define rforeach(t,p) for(t::reverse_iterator it=p.rbegin();it!=p.rend();++it)
#define all(p) p.begin(),p.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define FOREACH(t,p,tit) for(t::iterator tit=p.begin();tit!=p.end();++tit)
using namespace std;
char tiles[102][102];

int main()
{
    int w,h;
    while(cin >> w >> h)
    {
        if(w==0&&h==0){break;}
        rep(j,h)rep(i,w){cin >> tiles[i][j];}

        int x,y,nextx,nexty;
        x=0;
        y=0;
        int loop = 0;
        while(1)
        {
            if(tiles[x][y]=='.'){break;}
            if(tiles[x][y]=='x'){loop=1;break;}

            if(tiles[x][y]=='>')
            {
                nextx = x+1;nexty = y;
                tiles[x][y] = 'x';
                x = nextx;y = nexty;
                continue;
            }
            if(tiles[x][y]=='<')
            {
                nextx = x-1;nexty = y;
                tiles[x][y] = 'x';
                x = nextx;y = nexty;
                continue;
            }
            if(tiles[x][y]=='v')
            {
                nextx = x;nexty = y+1;
                tiles[x][y] = 'x';
                x = nextx;y = nexty;
                continue;
            }
            if(tiles[x][y]=='^')
            {
                nextx = x;nexty = y -1;
                tiles[x][y] = 'x';
                x = nextx;y = nexty;
                continue;
            }
        }
        if(loop){cout << "LOOP"<<endl;continue;}
        cout <<x << " "<<y << endl;

    }

    return 0;
}

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

int main(void) {
  char G[200][200];
  bool visited[200][200];
  int W, H;
  string str;
  
  while(cin >> H >> W) {
    if(W==0 && H==0) break;
    for(int i=0; i<H; i++) {
      cin >> str;
      for(int j=0; j<W; j++) {
	G[i][j] = str[j];
	visited[i][j] = false;
      }
    }
    
    int x=0, y=0;
    while(1) {
      if(visited[y][x]) { cout << "LOOP" << endl; break; }
      
      visited[y][x] = true;
      if(G[y][x] == '>') x++;
      else if(G[y][x] == 'v') y++;
      else if(G[y][x] == '^') y--;
      else if(G[y][x] == '<') x--;
      else if(G[y][x] == '.') { cout << x << " " << y << endl; break; }
    }

  }
  
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair



int main(){
    typedef vector<string> vs;
    int h,w;
    while(cin>>h>>w, h|w){
        vs G(h);
        for(auto & a: G) cin>>a;

        vector<vector<bool>> vis(h, vector<bool>(w,false));
        int cx = 0, cy = 0;
        const int dx[] = {1,0,-1,0};
        const int dy[] = {0,-1,0,1};

        map<char,int> m;
        m['>'] = 0, m['^'] = 1, m['<'] = 2, m['v'] = 3;

        while(1){
            if(vis[cy][cs]){
                cout << "LOOP" << endl;
                goto end;
            }
            vis[cy][cx] = true;
            char c = G[cy][cx];
            if(c=='.'){
                cout << cx << " " << cy << endl;
                goto end;
            }
            cx += dx[m[c]], cy += dy[m[c]];
        }
    end:;
    }
}

C++: #include<stdio.h>
#include<windows.h>

char masu[101][101];
int H,W,x,y;



int main()
{
	int i,j;
	int f,t1,t2;
	char temp;
	
	for(;;){
		x=0;
		y=0;
		f=0;
		
		scanf("%d %d", &H, &W);
		if(H==0)break;
		scanf("%c",&temp);
		
		for(i=0;i<H;i++){
			for(j=0;j<W+1;j++){
				scanf("%c",&masu[i][j]);
			}
		}
		for(;;){
			if(masu[y][x]==','){
				f=1;
				break;
			}
			t1=x;
			t2=y;
			if(masu[y][x]=='>')x++;
			else if(masu[y][x]=='<')x--;
			else if(masu[y][x]=='v')y++;
			else if(masu[y][x]=='^')y--;
			else if(masu[y][x]=='.')break;
			masu[t2][t1]=',';
		}
		if(f==1)puts("LOOP");
		else printf("%d %d\n",x,y);
	}
	return 0;
}