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<iostream>
using namespace std;

int main() {
	int x, y;
	while (cin >> x >> y, x, y) {
		char r[105][105];
		bool f[105][105];
		for (int i = 0;i < x;i++) {
			for (int j = 0;j < y;j++) {
				cin >> r[i][j];
				f[i][j] = false;
			}
		}

		int px = 0;
		int py = 0;
		int flg = 1;
		f[0][0] = true;

		while (1) {
			char a = r[px][py];
			if (a == '>') {
				py++;
				if (f[px][py] == true) {
					flg = 0;
					break;
				}
				else { f[px][py] = true; }
			}
			else if(a=='<'){
				py--;
				if (f[px][py] == true) {
					flg = 0;
					break;
				}
				else { f[px][py] = true; }
			}
			else if (a == 'v') {
				px++;
				if (f[px][py] == true) {
					flg =0 ;
					break;
				}
				else { f[px][py] = true; }
			}
			else if (a == '^') {
				px--;
				if (f[px][py] == true) {
					flg = 0;
					break;
				}
				else { f[px][py] = true; }
			}
			else { break; }
		}
		if (flg == 0)cout << "LOOP" << endl;
		else { cout << py << ' ' << px << endl; }

	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define debug puts
#define debugp printf
#define debugs scanf
using namespace std;

int main() {
  int mapx, mapy;
  int x, y, tmp0 = 0, tmp1 = 0;
  char map[150][150] = {0}, tmpc = 1;
  scanf("%d %d", &mapx, &mapy);
  while (mapx+mapy) {
    // debugs("%c", &tmpc);
    while (tmp0 < mapx) {
      tmp1 = 0;
      while (tmp1 < mapy) {
        // debugp("Debug: %d %d\n", tmp0, tmp1);
        scanf("%c", &map[tmp0][tmp1]);
        tmp1++;
      }
      // scanf("%c", &tmpc);
      tmp0++;
    }
    // debug("Debug: Ok.");
    tmp0 = 0, tmp1 = 0, tmpc = 1;
    x = 0, y = 0;
    while (tmpc) {
      if (map[x][y] == '>') y++;
      else if (map[x][y] == '<') y--;
      else if (map[x][y] == '^') x--;
      else if (map[x][y] == 'v') x++;
      else if (map[x][y] == '.') tmpc = 0;
      else {
        // debugp("Debug: %c %d %d\n", map[x][y], (x+1), (y+1));
        tmpc = 0;
      }
      // debugp("Debug: %c %d %d\n", map[x][y], (x+1), (y+1));
    }
    printf("%d %d\n", (x+1), (y+1));
    scanf("%d %d", &mapx, &mapy);
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int h, w; 
	while (cin >> h >> w) {
		char map[114][514];
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				cin >> map[i][j];
		int i = 0, j = 0;
		for (int p = 1; p < 100000; p++) {
			if (map[i][j] == '.') {
				cout << j << ' ' << i << endl;
				continue;
			}
			else if (map[i][j] == '>') j++;
			else if (map[i][j] == '<') j--;
			else if (map[i][j] == '^') i--;
			else if (map[i][j] == 'v') i++;
		}
		cout << "LOOP\n";
	}
}

C++: #include<iostream>
#include <stdlib.h>
#include<string>
using namespace std;

string map[200];
int j_map[200][200];
int* ans(int* x){
	if(j_map[x[0]][x[1]]==1){
		x[0]=x[1]=-1;
		return x;
	}else{
		j_map[x[0]][x[1]]=1;
		
		if(map[x[0]][x[1]]=='v'){
			x[0]++;
			return ans(x);
		}else if(map[x[0]][x[1]]=='<'){
			x[1]--;
			return ans(x);
		}else if(map[x[0]][x[1]]=='>'){
			x[1]++;
			return ans(x);
		}else if(map[x[0]][x[1]]=='^'){
			x[0]--;
			return ans(x);
		}else{
			return x;
		}
	}
}



int main(){
	int w,h;
	while(cin>>w,cin>>h,(w!=0)&&(h!=0)){
		for(int i=0;i<w;i++){
			cin>>map[i];
		}
		for(int i=0;i<w;i++){
			for(int j=0;j<h;j++){
				j_map[i][j]=0;
			}
		}
		
		int* x=(int *)malloc(sizeof(int)*3);
		x[0]=x[1]=0;
		x = ans(x);
		if(x[0]==-1){
			cout<<"LOOP"<<endl;
		}else{
			cout<<x[1]<<" "<<x[0]<<endl;
		}
	}
	
}

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

C++: #include <iostream>
#include <string>
#include <cstdio>
#define MAX_N 105

using namespace std;
int n,h,w;
int area[MAX_N][MAX_N];;
string s[MAX_N];

void move(int h,int w){
	if(area[h][w]==1){
		cout << "LOOP" << endl;
		return;
	}
	area[h][w]=1;
	
	switch(s[h][w]){

		case'>':
		move(h,w+1);
		return;
		break;

		case'<':
		move(h,w-1);
		return;
		break;

		case'v':
		move(h+1,w);
		return;
		break;

		case'^':
		move(h-1,w);
		return;
		break;

		case'.':
		cout << w<< " "<<h<<endl;
		return;
		break;
	}
	return;
}

int main(){
	while(1){
		cin >> h >> w;
		if(h==0&&w==0)break;
		for(int i=0;i<h;i++){
			cin >> s[i];
		}
		move(0,0);

	}
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int H, W; cin >> H >> W&&H;) {
		char c[12][12] = {};
		rep(i, 0, H)rep(j, 0, W)cin >> c[i][j];
		int cnt[12][12] = {};
		int i = 0, j = 0;
		while (true) {
			cnt[i][j]++;
			if (cnt[i][j] > 10) {
				cout << "LOOP" << endl;
				break;
			}
			else {
				bool flag = false;
				switch (c[i][j])
				{
				case '.':
					cout << j << " " << i << endl;
					flag = true;
					break;
				case '>':
					j++;
					break;
				case '<':
					j--;
					break;
				case '^':
					i--;
					break;
				case 'v':
					i++;
					break;
				default:
					break;
				}
				if (flag)break;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    while(true){
    char a[100][100];
    int h,w,n=0;
    cin>>h>>w;
    if(h==0 && w==0){
        exit(1);
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    h=0;
    w=0;
    n=0;
    while(true){
        n+=1;
        if(a[h][w]=='.'){
            break;
        }
        if(a[h][w]=='>'){
            w+=1;
        }
        if(a[h][w]=='<'){
            w-=1;
        }
        if(a[h][w]=='^'){
            h-=1;
        }
        if(a[h][w]=='v'){
            h+=1;
        }
        if(n==10001){
            break;
        }
    }
    if(n==10001){
        cout<<"LOOP"<<endl;
    }
    else{
        cout<<w<<" "<<h<<endl;
    }
}
}