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 <cstdio>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main() 
{
    int h,w;
    while (scanf("%d%d",&h,&w)) {
        if (h==0&&w==0) break;
        vector<string> map;
        for (int i=0; i<h; i++) {
            string in;
            cin>>in;
            map.push_back(in);
        }
        vector<vector<int> > went;
        for (int i=0; i<h; i++) {
            vector<int> num(w,0);
            went.push_back(num);
        }
        int ni=0, nj=0;
        bool flag=false;
        while (map[ni][nj]!='.') {
            if (went[ni][nj]==1) {
                flag=true;
                break;
            }
            went[ni][nj]++;
            if (map[ni][nj]=='>') {
                nj++;
            }
            else if (map[ni][nj]=='<') {
                nj--;
            }
            else if (map[ni][nj]=='^') {
                ni--;
            }
            else if (map[ni][nj]=='v') {
                ni++;
            }
        }
        if (flag) printf("LOOP\n");
        else printf("%d %d\n",ni,nj);
    }
}

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;
	    }
	  
	  looper[i][j]++;
	}
 
    }
        return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

string data[500];
bool sumi[500][500];
int nx,ny,ox,oy,ansx,ansy,ox2,oy2;
int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h==0&&w==0) break;
		REP(i,h) cin >> data[i];
		REP(i,500) REP(j,500) sumi[i][j] = false;
		nx = 0; ny = 0; ox = 0; oy = 0;
		ox2 = 0; oy2 = 0;
		bool flg = true;

		sumi[nx][ny] = true;
		while(flg){
			if(data[nx][ny]=='>') ny++;
			if(data[nx][ny]=='<') ny--;
			if(data[nx][ny]=='^') nx--;
			if(data[nx][ny]=='v') nx++;
			if(data[nx][ny]=='.'){
				ansx = nx;
				ansy = ny;
				flg = false;
			}
			if(sumi[nx][ny]){
				ansx = -1;
				flg = false;
			}
			sumi[nx][ny] = true;
			ox = nx;
			oy = ny;
			ox2 = ox;
			oy2 = oy;
		}
		if(ansx==-1) cout << "LOOP" << endl;
		else cout << ansy << " " << ansx << endl;
	}
}

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

using namespace std;

int main(void){
  int h, w;

  while(cin >> h >> w){
	if((h|w) == 0) break;
	bool visited[h][w];
	bool isloop = false;
	char arrow[h][w];
	string str;
	for(int i=0;i<h;i++){
	  cin >> str;
	  for(int j=0;j<w;j++){
		arrow[i][j] = str[j];
	  }
	}
	
	int x=0,y=0;
	memset(visited, false, sizeof(visited));
	while(arrow[x][y] != '.'){
	  if(visited[x][y]){
		isloop = true;
		break;
	  }
	  visited[x][y] = true;
	  if(arrow[x][y] == '>'){
		y++;
	  }else if(arrow[x][y] == '^'){
		x--;
	  }else if(arrow[x][y] == 'v'){
		x++;
	  }else{
		y--;
	  }
	}
	if(isloop){
	  cout << "LOOP" << endl;
	}else{
	  cout << y << " " << x << endl;
	}
  }
}

C++: #include<stdio.h>
#include<string.h>
int main(void)
{
	int a,b,H,W,c[100][100]={0},d;
	scanf("%d %d",&H,&W);
	char map[100][101];
	for(d=0;d<H;d++)
		scanf("%s",map[d]);
	for(a=0,b=0;;)
	{
		c[a][b]++;
		if(c[a][b]==2)
		{
			printf("LOOP\n");
			break;
		}
		if(map[a][b]=='>')
			b++;
		else if(map[a][b]=='<')
			b--;
		else if(map[a][b]=='^')
			a--;
		else if(map[a][b]=='v')
			a++;
		else
		{
			printf("%d %d\n",a,b);
			break;
		}
	}	
}

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

int H,W;
char data[101][101];
char done[101][101];

int X,Y;

int main()
{
  scanf("%d%d",&H,&W);

  if(H==0&&W==0) return 0;

  memset(done, 0, sizeof(done));

  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      scanf(" %c",&data[i][j]);

  X = Y = 0;
  for(;;){
    if(done[X][Y]){
      puts("LOOP");
      goto NEXT;
    }

    done[X][Y] = 1;

    switch(data[X][Y]){
    case '>':
      Y+=1;
      break;
    case '<':
      Y-=1;
      break;
    case 'v':
      X+=1;
      break;
    case '^':
      X-=1;
      break;
    case '.':
      printf("%d %d\n",Y,X);
      goto NEXT;
    }
  }

 NEXT:
  main();
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

const int dy[4]={-1,0,1,0},dx[4]={0,1,0,-1};

int main(){
	int H,W;
	while(cin>>H>>W,H||W){
		char fld[101][101];
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>fld[i][j];
			}
		}
		int y=0,x=0;
		bool used[101][101],loop=false;
		while(fld[y][x]!='.'){
			if(used[y][x]==true){
				loop = true; break;
			}
			used[y][x] = true;
			char c = fld[y][x];
			int dir;
			if(c=='^') dir = 0;
			else if(c=='>') dir = 1;
			else if(c=='v') dir = 2;
			else dir = 3;
			y += dy[dir]; x += dx[dir];
		}
		if(loop==true) puts("LOOP");
		else printf("%d %d\n",x,y);
	}
    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;
	    }
	  
	  looper[i][j]++;
	}
 
    }
        return 0;
}

C++: #include<stdio.h>
int main()
{
	char a[100][101];
	int h,w,i,j;
	while(scanf("%d%d",&h,&w), h)
	{
		for(i = 0; i < h; ++i)
			scanf("%s", a[i]);
		i = j = 0;
		bool isPlaced[100][100] = {false};
		while(a[i][j] != '.')
		{
			if(isPlaced[i][j])
			{
				printf("LOOP\n");
				goto NEXT;
			}
			isPlaced[i][j] = true;
			switch(a[i][j])
			{
			case '>': ++j; break;
			case '<': --j; break;
			case '^': --i; break;
			case 'v': ++i; break;
			}
		}
		printf("%d %d\n", j, i);
NEXT:
		;
	}
	return 0;
}