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<algorithm>
#include<string>
#include<cstring>
using namespace std;

int main(){

  string str[1000];
  int a,b;

  while(cin >> a >> b, a, b){

    for(int i=0;i<a;i++) cin >> str[i];

    int x = 0,y = 0,count = 0,t = 0;

    while(1){
      if(count == 1000000){
	t = 1;
	break;
      }

      if(str[x][y] == '>') y++;
      else if(str[x][y] == '<') y--;
      else if(str[x][y] == '^') x--;
      else if(str[x][y] == 'v') x++;
      else break;
      count++;
    }

    if(t == 1) cout << "LOOP" << endl;
    else cout << y << " " << x << endl;

  }
}

C++: #include <stdio.h>

int main(void){
	int i, j;
	int x, y;
	int w, h;
	char tile[128][128];
	int tile2[128][128];
	
	while (scanf("%d %d", &h, &w), h != 0 || w != 0){
		for (i = 0; i < h; i++){
			scanf("%s", tile[i]);
			for (j = 0; j < w; j++){
				tile2[i][j] = 0;
			}
		}
		
		x = 0; y = 0;
		while (tile[x][y] != '.' && tile2[x][y] < 2){
			tile2[x][y]++;
			if (tile[x][y] == '^') x--;
			if (tile[x][y] == 'v') x++;
			if (tile[x][y] == '>') y++;
			if (tile[x][y] == '<') y--;
		}
		
		if (tile2[x][y] > 1) printf("LOOP\n");
		else printf("%d %d\n", y, x);
		
	}
	return (0);
}

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

using namespace std;

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




int main(void){
	int w,h;
	char map[100][100];
	while(cin >> h >> w,w|h){
		rep(j,h)
			rep(i,w)
				cin >> map[i][j];
		int x=0,y=0;
		while(true){
			if(map[x][y]=='@'){
				cout << "LOOP" << endl;
				break;
			}
			if(map[x][y]=='>'){
				x++;
				map[x-1][y]='@';
			}else if(map[x][y]=='<'){
				x--;
				map[x+1][y]='@';
			}else if(map[x][y]=='v'){
				y++;
				map[x][y-1]='@';
			}else if(map[x][y]=='^'){
				y--;
				map[x][y+1]='@';
			}else{
				cout << x << " " << y << endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	int h,w,x,y;
	char dp[150][150];
	while(true){
	cin>>h>>w;
	if(h==0&&w==0)
		break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>dp[i][j];
		}
	}
	x=0,y=0;
	int i=0;
	bool loop=false;
	while(true){
		if(dp[x][y]=='>')
			y+=1;
		if(dp[x][y]=='<')
			y-=1;
		if(dp[x][y]=='^')
			x-=1;
		if(dp[x][y]=='v')
			x+=1;
		if(dp[x][y]=='.')
			break;
		i++;
		if(i==10100){
			cout<<"LOOP"<<endl;
			loop=true;
		}
	}
	if(loop==false)
	cout<<y<<" "<<x<<endl;
	}
	return 0;
}

C++: #include <stdio.h>
#define U 1
#define D 2
#define R 3
#define L 4
#define MAX 100

int main(void){
    int dx[L+1] = {0,0,0,1,-1};
    int dy[L+1] = {0,-1,1,0,0};
    int pnl[MAX][MAX];
    int visited[MAX][MAX];
    char buf[MAX+1];
    int h,w,x,y,dir;
    
    while (scanf("%d %d",&h, &w)){
        if (h==0 && w==0) break;
        // load
        for (int i=0; i<h; i++){
            scanf("%s", buf);
            for (int j=0; j<w; j++){
                visited[j][i] = pnl[j][i] = 0;
                switch (buf[j]){
                    case '^' : pnl[j][i]=U; break;
                    case 'v' : pnl[j][i]=D; break;
                    case '>' : pnl[j][i]=R; break;
                    case '<' : pnl[j][i]=L; break;
                }
            }
        }
        // move
        x = y = 0;
        while(pnl[x][y] && !visited[x][y]){
            printf("%d %d\n", x,y);
            visited[x][y]=1;
            dir = pnl[x][y];
            x += dx[dir];
            y += dy[dir];
        }
        if (pnl[x][y]){
            printf("LOOP\n");
        } else {
            printf("%d %d\n", x,y);
        }
    }
    
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <string.h>

using namespace std;
bool flag[101][101];
char field[101][101];

void DFS(int y, int x)
{
	if(flag[y][x] == true)
	{
		cout << "LOOP" << endl;
		return;
	}
	flag[y][x] = true;
	if(field[y][x] == '.')
	{
		cout << x << " " << y << endl;
	}
	else if(field[y][x] == '>')
	{
		DFS(y, x + 1);
	}
	else if(field[y][x] == '<')
	{
		DFS(y, x - 1);
	}
	else if(field[y][x] == '^')
	{
		DFS(y - 1, x);
	}
	else if(field[y][x] == 'v')
	{
		DFS(y + 1, x);
	}
}

void solve()
{
	int W, H;
	while(cin >> H >> W, W || H)
	{
		memset(flag, 0, sizeof(flag));
		memset(field, 0, sizeof(field));
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				cin >> field[i][j];
			}
		}
		DFS(0, 0);
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<iostream>
using namespace std;
int main(void)
{
  int h,w;
  while(true)
    {
      cin>>h>>w;
      if(h==0 && w==0)break;
      char str[h][w];
      int looper[h][w];
      for(int i=0;i<h;i++)
	{
	  for(int j=0;j<w;j++)
	    {
	      cin>>str[i][j];
	      looper[i][j]=0;
	    }
	}
      int i=0,j=0;
      
      while(true)
	{
	  if(str[i][j]=='>')
	    {
	      
	      j++;
	    }
	  else if(str[i][j]=='<')
	    {
	      j--;
	      
	    }
	  else if(str[i][j]=='v')
	    {
	      i++;
	    }
	  else 
	    {
	      i--;
	    }
	  
	  if(str[i][j]=='.')
	    {
	      cout<<j<<" "<<i<<endl;
	      break;
	    }
	  else if(looper[i][j]==1)
	    {
	      cout<<"LOOP"<<endl;
	      break;
	    }
	  
	  loop[i][j]++;
	}
 
    }
        return 0;
}

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

using namespace std;

int main(){
    int w,h;
    int i,j;
    while(1){
        cin >> w;
        cin >> h;
        if(w == 0 || h == 0) break;
        vector< vector<char> > v(101, vector<char>(101));
        for(j=0;j<h;++j){
            for(i=0;i<w;++i){
                cin >> v[i][j];
            }
        }
        int mi = 0, mj = 0;
        while(true){
            char c = v[mi][mj];
            v[mi][mj] = '#';
            if(c == '>') mi++;
            else if(c == '<') mi--;
            else if(c == '^') mj--;
            else if(c == 'v') mj++;
            else if(c == '#'){
                cout << "LOOP" << endl;
                break;
            } else if( c == '.' ){
                cout << mi << ' ' << mj << endl;
                break;
            }
        }
    }
    return 0;
}

C++: #include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	stringstream buff;
	while(n!=0 && m!=0){
		map<string,int> table;
		vector<string> args;
		for(int x=0;x<n;++x){
			string line;
			cin>>line;
			args.push_back(line);
		}
		int x=0,y=0;
		bool flag = true;
		while(args[x][y]!='.' && flag){
			stringstream buf;
			buf<<x<<":"<<y;
			if(table[buf.str()]){
				flag = false;
			}else{
					table[buf.str()]=100;
				switch(args[x][y]){
					case '>':
						++y;
						break;
					case '<':
							--y;
						break;
					case 'v':
						++x;
						break;
					case '^':
						--x;
						break;
						
				}
			}
		}
		if(flag)buff<<y<<" "<<x<<"\n";
		else	buff<<"LOOP\n";
		cin>>n>>m;
	}
	cout<<buff.str();
	return 0;
}