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>
#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][cx]){
                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 <cstdio>
#include <cstring>

using namespace std;

int main(){
	int n,m,k,l;
	char a[105][105];
	while(1){
		scanf("%d %d",&n,&m);
		if( n==0 && m==0 ) break;
		k=0; l=0;
		for(int i=0 ; i<n ; i++ ){
			scanf("%s",&a[i]);	
		}
		int b[105][105]={0};
		while(1){
			if(a[k][l]=='.'){
				printf("%d %d\n",l,k);
				break;
			}
			if(b[k][l]==1){
				printf("LOOP\n");
				break;
			}
			if(a[k][l]=='>'){
				b[k][l]=1;
				l++;
				continue;
			}
			if(a[k][l]=='v'){
				b[k][l]=1;
				k++;
				continue;
			}
			if(a[k][l]=='<' ){
				b[k][l]=1;
				l--;
				continue;
			}
			if(a[k][l]=='^' ){
				b[k][l]=1;
				k--;
				continue;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;



int main(void){

int w, h;
string ss;
	while(cin >> h >> w ){
		if(h==0 && w==0 || cin.eof()) break;
		vector<string> bd(h);
		vector<vector<char> > lc(h,vector<char>(w,' '));
		rep(i,h) cin >> bd[i];
		int y=0, x=0, loop=0;
		while(1){
			if(x<0 || y<0 || x>=w || y >=h) {loop=99;break;}
			if(lc[y][x]=='z'){ loop=1; break; }
			lc[y][x] = 'z';
			if(bd[y][x]=='.') break;
			else if(bd[y][x]=='>') x++;
			else if(bd[y][x]=='<') x--;
			else if(bd[y][x]=='^') y--;
			else if(bd[y][x]=='v') y++;
		}
		if(loop>0 && loop < 90) cout << "LOOP" << endl;
		else if(loop==0) cout << x << " " << y << endl;
	}
	return 0;
	
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define EQ(a,b) (abs((a)-(b))<EPS)
char map[110][110];
int main()
{
	while(1)
	{
		int w,h;
		cin >> w >> h;
		if(w==0&&h==0)break;
		for(int i=0;i<w;i++)
		{
			for(int j=0;j<h;j++)
			{
				cin >> map[i][j];
			}
		}
		int x=0,y=0;
		int count=0;
		bool flag=false;
		while(1)
		{
			if(map[x][y]=='>')
			{
				y++;
			}
			if(map[x][y]=='<')
			{
				y--;
			}
			if(map[x][y]=='v')
			{
				x++;
			}
			if(map[x][y]=='^')
			{
				x--;
			}
			if(map[x][y]=='.')
			{
				break;
			}
			count++;
			if(count>11000)
			{
				flag=true;
				break;
			}

		}
		if(flag)
		{
			cout << "LOOP" << endl;
		}
		else
		{
			cout << y << ' ' << x << endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
char s[101][101];
int n,m,a[100][100],c;
using namespace std;
int dfs(int y,int x){
  if(a[y][x]++)return 0;
  if(s[y][x]=='.'){cout<<x<<' '<<y<<endl;c++;}
  else if(s[y][x]=='^')dfs(y-1,x);
  else if(s[y][x]=='v')dfs(y+1,x);
  else if(s[y][x]=='>')dfs(y,x+1);
  else if(s[y][x]=='<')dfs(y,x-1);
  if(c)return 1;
  return 0;
}
int main(){
  while(cin>>n>>m,n){c=0;
    rep(i,100)rep(j,100)a[i][j]=0;
    rep(i,n)rep(j,m)cin>>s[i][j];
    if(!dfs(0,0))cout<<"LOOP"<<endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
void tile(int *x,int *y,char d[101][101] ){
	if(d[*y][*x]=='m')
		*x=50000;
	else if(d[*y][*x]!='.'){
	if(d[*y][*x]=='>'){
	d[*y][*x]='m';
		*x=*x+1;
	}
	else if(d[*y][*x]=='<'){
	d[*y][*x]='m';
		*x=*x-1;
	}
	else if(d[*y][*x]=='^'){
		d[*y][*x]='m';
		*y=*y-1;
	}
	else if(d[*y][*x]=='v'){
		d[*y][*x]='m';
		*y=*y+1;
	}
		tile(x,y,d);
	}
	
}
int main(){
	
	int w,h;
	
	while(cin>>h>>w,h!=0&&w!=0){
	char d[101][101];
	int x=0,y=0;
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>d[i][j];
		}
	}
	tile(&x,&y,d);
	
	if(x==50000)
		cout<<"LOOP"<<endl;
	else
		cout<<x<<" "<<y<<endl;
	}
	
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int w,h;
  string a[102];
  while(cin>>w>>h,w){
    for(int i=0;i<102;i++){
      a[i]="";
    }
    for(int i=0;i<w;i++){
      cin>>a[i];
    }
    int x=0,y=0;
    while(true){
      if(a[x][y]=='.'){cout<<x<<' '<<y<<endl;break;}
      else  if(a[x][y]=='o'){cout<<"LOOP"<<endl; break;}
      else if(a[x][y]=='>'){a[x][y]='o'; y++;}
      else if(a[x][y]=='<'){a[x][y]='o'; y--;}
      else if(a[x][y]=='^'){a[x][y]='o'; x--;}
    else if(a[x][y]=='v'){a[x][y]='o'; x++;}
    }
  }
}

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 >> W >> H) {
    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;
}