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>

using namespace std;

int main() {
  int h, w;
  while (cin >> h >> w, h) {
    vector<vector<string>> map(h, vector<string>(w));

    for (auto &seq : map) {
      for (auto &v : seq) {
        char c;
        cin >> c;
        v = c;
      }
    }

    int cx = 0;
    int cy = 0;
    while (true) {
      string str = map[cy][cx];
      map[cy][cx] = "0";
      if (str == ">") {
        ++cx;
      } else if (str == "<") {
        --cx;
      } else if (str == "^") {
        --cy;
      } else if (str == "v") {
        ++cy;
      } else if (str == ".") {
        cout << cx << " " << cy << endl;
        break;
      } else if (str == "0") {
        cout << "LOOP" << endl;
        break;
      }
    }
  }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
	int a, b;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		char data[102][102];
		int bb[a][b] = { 0 };
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				cin >> data[i][j];
			}
		}

		int H = 0, W = 0;
		int loop = 0;
		while (1) {
			if (data[H][W] == '<') {
				bb[H][W] = 1;
				W -= 1;
				if (bb[H][W] == 1) {
					loop = 1;
					break;
				}

			} else if (data[H][W] == '>') {
				bb[H][W] = 1;
				W += 1;
				if (bb[H][W] == 1) {
					loop = 1;
					break;
				}
			} else if (data[H][W] == 'v') {
				bb[H][W] = 1;
				H += 1;
				if (bb[H][W] == 1) {
					loop = 1;
					break;
				}
			} else if (data[H][W] == '^') {
				bb[H][W] = 1;
				H -= 1;
				if (bb[H][W] == 1) {
					loop = 1;
					break;
				}
			} else {
				break;
			}
		}
		if (loop != 1) {
			printf("%d %d\n", W, H);
		} else {
			printf("LOOP\n");
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;


int main(){

   int height,width,count,limit,row,col;
   char table[100][101];

   while(true){
	   scanf("%d %d",&height,&width);
	   if(height == 0 && width == 0)break;

	   for(int i = 0; i < height; i++){
		   scanf("%s",table[i]);
	   }

	   count = 0;
	   row = 0; col = 0;
	   limit = height*width;

	   while(table[row][col] != '.' && count < limit){
		   switch(table[row][col]){
		   case '>':col++;
		   	   	   count++;
		   	   	   break;
		   case '<':col--;
		   	   	   count++;
		   	   	   break;
		   case '^':row--;
		   	   	   count++;
		   	   	   break;
		   case 'v':row++;
		   	   	   	count++;
		   	   	   	break;
		   }
	   }

	   if(count >= limit){
		   printf("LOOP\n");
	   }else{
		   printf("%d %d\n",col,row);
	   }

   }

    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T x; cin >> x; return x; }

signed main()
{
	while (true) {
		int h = in(), w = in();
		if (h == 0 && w == 0) {
			break;
		}
		vector<vector<char>>tile(h, vector<char>(w));
		vector<vector<bool>>step(h, vector<bool>(w, false));
		REP(i, h) {
			REP(j, w) {
				tile[i][j] = in<char>();
			}
		}
		int x = 0, y = 0;
		while (true) {
			step[y][x] = true;
			switch (tile[y][x]) {
			case '>':
				++x;
				break;
			case '<':
				--x;
				break;
			case '^':
				--y;
				break;
			case 'v':
				++y;
				break;
			}
			if (tile[y][x] == '.') {
				cout << x << ' ' << y << endl;
				break;
			} else if (step[y][x]) {
				cout << "LOOP" << endl;
				break;
			}
		}
	}
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	int W, H;

	while(cin >> H >> W, H) {
		vs tile(H);
		vvi field(H, vi(W));

		REP(i, H) {
			cin >> tile[i];
		}

		int x = 0, y = 0;
		
		while(field[x][y] != 1) {
			field[x][y] = 1;
			switch(tile[x][y]) {
			case '^':
				x--;
				break;
			case '>':
				y++;
				break;
			case 'v':
				x++;
				break;
			case '<':
				y--;
				break;
			case '.':
				cout << y << " " << x << endl;
				goto next;
			}
		}
		cout << "LOOP" << endl;

		next:;
	}

	return 0;
}

C++: #include <iostream>

int main(){
  int a,b;
  while(std::cin>>a>>b){
    if(!a&&!b)return 0;
    char c[101][101];
    for(int y=0;y<a;y++){
      std::string s;
      std::cin>>s;
      for(int x=0;x<b;x++)
        c[y][x] = s[x];
    }
    int r[101][101]={0},t_x=0,t_y=0;
    while(c[t_y][t_x] != '.'){
      switch(c[t_y][t_x]){
      case '>':
        t_x++;
        break;
      case '<':
        t_x--;
        break;
      case 'v':
        t_y++;
        break;
      case '^':
        t_y--;
        break;
      }
      if(r[t_y][t_x]>1)break;
      r[t_y][t_x]++;
    }
    if(r[t_y][t_x]>1)std::cout<<"LOOP"<<std::endl;
    else{std::cout<<t_x<<","<<t_y;}
  }
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,i,j,f,g,c[500][500],v;
	char z[1000][1000],x;
	while(1){
		v=0;
		scanf("%d %d",&a,&s);
		if(a==0&&s==0)	break;
		for(i=0;i<s;i++){
			for(j=0;j<a;j++)
				z[i][j]=0;
		}
		for(i=0;i<a;i++){
			scanf("%s",z[i]);
		}
		for(i=0;i<s;i++){
			for(j=0;j<a;j++){
				c[i][j]=0;
			}
		}
		f=0;
		g=0;
		while(1){
			if(z[f][g]=='>'){
				g++;
				c[f][g]++;
			}
			else if(z[f][g]=='<'){
				g--;
				c[f][g]++;
			}
			else if(z[f][g]=='^'){
				f--;
				c[f][g]++;
			}
			else if(z[f][g]=='v'){
				f++;
				c[f][g]++;	
			}
			if(z[f][g]=='.')	break;
			if(c[f][g]==2){
				v=1;
				break;
			}
		}
		if(v==1)
			printf("LOOP\n");
		else
			printf("%d %d\n",g,f);
	}
		return 0;
}