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 <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;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

int n, m;
string fi[110];

int main() {
    while (cin >> n >> m) {
        if (n == 0) break;
        for (int i = 0; i < n; ++i) cin >> fi[i];
        bool loop = false;
        bool seen[110][110] = {0};
        int x = 0, y = 0;
        while (fi[x][y] != '.') {
            if (fi[x][y] == '>') ++y;
            if (fi[x][y] == 'v') ++x;
            if (fi[x][y] == '<') --y;
            if (fi[x][y] == '^') --x;
            if (seen[x][y]) { loop = true; break; }
            seen[x][y] = true;
        }
        if (!loop) cout << y << " " << x << endl;
        else puts("LOOP");
    }
    return 0;
}

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

char tile[100][100];
bool memo[100][100];

template <typename T>
void init(T a[100][100]) {
  for(int i = 0; i < 100; ++i) {
	for(int j = 0; j < 100; ++j) {
	  a[i][j] = 0;
	}
  }
}

void Step(char tile[100][100]) {
  int h = 0, w = 0;

  while(1) {
	if(memo[h][w] == 1) {
	  cout << "LOOP" << endl;
	  break;
	}
	
	// '>'??????????????\???????????????
	if(tile[h][w] == '>') {
	  memo[h][w] = 1;
	  w++;
	}
	// '<'??????????????\???????????????
	else if(tile[h][w] == '<') {
	  memo[h][w] = 1;
	  w--;
	}
	
	// '^'??????????????\???????????????
	else if(tile[h][w] == '^') {
	  memo[h][w] = 1;
	  h--;
	}

	// 'v'??????????????\???????????????
	else if(tile[h][w] == 'v') {
	  memo[h][w] = 1;
	  h++;
	}

	// '.'??????????????\???????????????
	else {
	  cout << w << " " << h << endl;
	  break;
	}
  }// END:while

}

int main() {
  int H, W;
  while(cin >> H >> W) {
	if(H == 0 && W == 0) break;

	init<bool>(memo);
	init<char>(tile);
	
	for(int i = 0; i < H; ++i) {
	  for(int j = 0; j < W; ++j) {
		cin >> tile[i][j];
	  }
	}
	
	Step(tile);
  }

  return 0;
}

C++: #include<stdio.h>
int a,b,limx,limy;
char s[102][102];
int pass[102][102];
void check(int x,int y){
    if(pass[x][y]!=1){
        a=x,b=y;
        pass[x][y]=1;
        if(s[x][y]=='^'&&x-1>=0)
        check(x-1,y);
        if(s[x][y]=='v'&&x+1<limx)
        check(x+1,y);
        if(s[x][y]=='>'&&y+1<limy)
        check(x,y+1);
        if(s[x][y]=='<'&&y-1>=0)
        check(x,y-1);
    }
    else
    a=-1;
}
main(){
    int x,y,i,j;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)
        break;
        limx=x;limy=y;
        for(i=0;i<x;i++)
        for(j=0;j<y;j++)
        pass[x][y]=0;
        for(i=0;i<x;i++)
        scanf("%s",&s[i]);
        check(0,0);
        if(a!=-1)
        printf("%d %d\n",b,a);
        else
        printf("LOOP\n");
    }
}