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<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[110][110];

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 <bits/stdc++.h>
using namespace std;
int a,b;

int main() {
while(cin>>a>>b){
if(a==0&&b==0){break;}
string data[a];
int b[a][b]={0};
for (int i = 0; i < a; ++i) {
	cin>>data[i];
}
int H=0,W=0;
int loop=0;
while(1){
if (data[H][W]=='<') {
b[H][W]=1;
W-=1;
if(b[H][W]==1){loop=1;break;}

} else if (data[H][W]=='>')  {
b[H][W]=1;
W+=1;
if(b[H][W]==1){loop=1;break;}
} else if (data[H][W]=='v')  {
	b[H][W]=1;
	H+=1;
if(b[H][W]==1){loop=1;break;}
} else if (data[H][W]=='^')  {
	b[H][W]=1;
	H-=1;
if(b[H][W]==1){loop=1;break;}
}else{
break;
}
}
if(loop==1){cout<<"LOOP"<<endl;}
else{cout<<W<<" "<<H<<endl;}
}
return 0;
}

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

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

    vector<string> tile(H);
    for (int i = 0; i < H; ++i)
      cin >> tile[i];

    int x = 0, y = 0;
    bool loop = false;
    vector<vector<int> > visited(H, vector<int>(W, 0));
    while (tile[y][x] != '.') {
      if (visited[y][x]) {
	loop = true;
	break;
      }

      visited[y][x] = 1;
      if (tile[y][x] == '>')
	++x;
      else if (tile[y][x] == '<')
	--x;
      else if (tile[y][x] == 'v')
	++y;
      else if (tile[y][x] == '^')
	--y;
    }

    if (loop)
      cout << "LOOP" << endl;
    else
      cout << x << " " << y << endl;
  }
  return 0;
}

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

char m[100][100];

int main()
{
	int h, w;
	while (cin >> h >> w, h+w)
	{
		for (int y = 0; y < h; y++)
		{
			for (int x = 0; x < w; x++)
			{
				cin >> m[x][y];
			}
		}
		int x = 0;
		int y = 0;
		for (int i = 0; i <= w * h; i++)
		{
			if (m[x][y] == '.')
			{
				cout << x << ' ' << y << endl;
				break;
			}
			else if (m[x][y] == '>') x++;
			else if (m[x][y] == '<') x--;
			else if (m[x][y] == 'v') y++;
			else if (m[x][y] == '^') y--;
			if (i == w * h) cout << "LOOP" << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int px,py; 
int w,h,f[100][100];

bool cheak(){
  if(f[px][py] == 0){
    cout << "LOOP" << endl;
    return true;
  }
  return false;
}

int main(){

  char ma[100][100];
  while(  cin >> h >> w,w + h ){
    for(int i = 0 ; i < h ; i++){
      for(int j = 0 ; j < w ; j++){
	cin >> ma[j][i];
	f[j][i] = 1;
      }
    }

    px = 0,py = 0; 
    while(1){
      if(ma[px][py] == '>' ){
	px++;
	if(cheak())break;
      } else if(ma[px][py] == 'v' ){
	py++;
	if(cheak())break;
      }else if(ma[px][py] == '<' ){
	px--;
	if(cheak())break;
      }else if(ma[px][py] == '^' ){
	py--;
	if(cheak())break;
      } else {
	cout << px << " " << py << endl;
	break;
      }
      f[px][py] = 0;
    }
  }
}

C++: #include<iostream>

void move(int, int);

char tiles[100][100];
bool mem[100][100];

int main()
{
  int H, W;
  while(true)
  {
    std::cin >> H >> W;
    if(!H && !W)
      break;

    for(int i = 0; i < H; i++)
      std::cin >> tiles[i];
    
    move(0, 0);
  }
}

void move(int x, int y)
{
  if(mem[y][x])
  {
    std::cout << "LOOP" << std::endl;
    return;
  }

  mem[y][x] = true;

  switch(tiles[y][x])
  {
    case '<':
      move(x - 1, y);
      return;
    case '>':
      move(x + 1, y);
      return;
    case '^':
      move(x, y - 1);
      return;
    case 'v':
      move(x, y + 1);
      return;
    case '.':
      std::cout << x << " " << y << std::endl;
      return;
  }
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#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 ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int h, w;
	while (cin >> h >> w, h){
		vector<vector<bool>> memo(h,vector<bool>(w,false));
		int x = 0,y=0;
		vector<string> vs(h);
		REP(i, h)
			cin >> vs[i];
		bool loop=false;
		while(vs[y][x]!='.'){
			if (memo[y][x]){
				loop = true;
				break;
			}
			memo[y][x] = true;
			if (vs[y][x] == '<')x--;
			else if (vs[y][x] == '^')y--;
			else if (vs[y][x] == '>')x++;
			else if (vs[y][x] == 'v')y++;
		}
		if (loop)
			cout << "LOOP" << endl;
		else
			cout << x << " " << y << endl;
	}
}