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

C++: #include <iostream>
#include <vector>

using namespace std;

int main()
{
    int h, w;

    while (cin >> h >> w, h || w) {
        vector<string> map(h);
        vector<vector<bool> > memo(h, vector<bool>(w));

        for (int i = 0; i < h; i++) {
            cin >> map[i];
            for (int j = 0; j < w; j++)
                memo[i][j] = false;
        }

        int x, y;
        x = y = 0;
        while (true) {
            if (memo[y][x]) {
                cout << "LOOP" << endl;
                break;
            }
            memo[y][x] = true;
            if (map[y][x] == '.') {
                cout << x << " " << y << endl;
                break;
            }
            
            if (map[y][x] == '>') 
                x++;
            else if (map[y][x] == '<')
                x--;
            else if (map[y][x] == 'v')
                y++;
            else
                y--;
        }
    }

    return 0;
}

C++: #include<iostream>

using namespace std;
int H, W;
int x = 0, y = 0;
int rog[100][100];
bool check(){
	if (rog[x][y] == 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];
				rog[j][i] = 1;
			}
		}

		x = 0, y = 0;
		while (1){
			if (ma[x][y] == '>'){
				x++;
				if (check())break; 
			}
			else if(ma[x][y]=='v'){
				y++;
				if (check()) break; 
			}
			else if (ma[x][y] == '<'){
				x--;
				if (check()) break; 
			}
			else if (ma[x][y] == '^'){
				y--;
				if (check())break; 
			}
			else {
				cout << x << " " << y << endl;
				break;
			}
			
			rog[x][y] = 0;

		}
	}
}