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>

int main()
{
	char tile[100][100];
	int n;
	while(1)
	{
		int r,c;
		std::cin>>r>>c;
		std::cin.ignore();
		if(r==0&&c==0)break;
		
		for(int i=0;i<r;i++)
		{
			char buf[101];
			std::cin.getline(buf,101);
			for(int j=0;j<c;j++)
			{
				tile[i][j]=buf[j];
			}
		}
		
		int x=0,y=0;
		bool moving=true;
		while(moving)
		{
			switch(tile[y][x])
			{
			case '.':
				std::cout<<x<<' '<<y<<std::endl;
				moving=false;
				break;
			case '>':
				tile[y][x]='1';
				x++;
				break;
			case '<':
				tile[y][x]='1';
				x--;
				break;
			case '^':
				tile[y][x]='1';
				y--;
				break;
			case 'v':
				tile[y][x]='1';
				y++;
				break;
			case '1':
				std::cout<<"LOOP"<<std::endl;
				moving=false;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;
char map[100][100];
int H, W;
int x = 0, y = 0;
int rog[100][100];
bool check(){
	if (rog[x][y] == 0){
		cout << "LOOP" << endl;
		return true;
	}
	else{
		return false;
	}
}
int main(){
	
	while (cin >> H >> W){

		int x = 0, y = 0;
		map[100][100] = {};
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> map[i][j];
				rog[i][j] = 1;
			}
		}
		while (1){
			if (map[x][y] == '>'){
				x++;
				if (check() == true){ break; }
			}
			else if(map[x][y]=='v'){
				y--;
				if (check() == true){ break; }
			}
			else if (map[x][y] == '<'){
				x--;
				if (check() == true){ break; }
			}
			else if (map[x][y] == '^'){
				y++;
				if (check() == true){ break; }
			}
			else {
				cout << x << " " << y << endl;
				break;
			}
			
			rog[x][y] = 0;

		}
	}
	return 0;
}

C++: #include<stdio.h>
int a,b,limx,limy;
char s[102][102];
int pass[102][102];
void check(int x,int y){
    printf("move to %d %d\n",x,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.h>
using namespace std;

struct zahyou{
	int x;
	int y;
};

int main(){
	
	int tx,ty,count;
	char map[100][100];
	bool flag;
	struct zahyou now;
	
	
	
	while(cin>>tx>>ty,tx&&ty){
		
		flag=false;
		now.x=0;
		now.y=0;
		memset(map,'\0',sizeof(map));
		
		for(int i=0;i<tx;i++){
			for(int j=0;j<ty;j++){
				cin>>map[i][j];
			}
		}
		
		while(1){

			if(map[now.y][now.x]=='.'){
				cout<<now.x<<" "<<now.y<<endl;
				break;
			}
			else if(map[now.y][now.x]=='1'){
				cout<<"LOOP"<<endl;
				break;
			}

			if(map[now.y][now.x]=='>'){
				map[now.y][now.x]='1';
				now.x++;
			}
			else if(map[now.y][now.x]=='<'){
				map[now.y][now.x]='1';
				now.x--;
			}
			else if(map[now.y][now.x]=='v'){
				map[now.y][now.x]='1';
				now.y++;
			}
			else if(map[now.y][now.x]=='^'){
				map[now.y][now.x]='1';
				now.y--;
			}
		}
	}
}

C++: #include<iostream>
#include<cstring>
using namespace std;
char mas[101][101];
int main(){
  int h,w,x,y;
  while(1){
    x=0,y=0;
    cin >> h >> w;
    if(h==0&&w==0){break;}
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> mas[i][j];
      }
    }
    while(1){
	if(mas[x][y]=='>'){
	  mas[x][y]='1';
	  y++;
	}else if(mas[x][y]=='<'){
	  mas[x][y]='1';
	  y--;
	}else if(mas[x][y]=='v'){
	  mas[x][y]='1';
	  x++;
	}else if(mas[x][y]=='^'){
	  mas[x][y]='1';
	  x--;
	}else if(mas[x][y]=='.'){
	  break;
	}else if(mas[x][y]=='1'){
	  x=-1;
	  break;
      }
    }
    if(x!=-1){
      cout <<y<<" "<<x<<endl;
    }else if(x==-1){
      cout<<"LOOP"<<endl;
    }
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int H,W,x,y;
  while(cin>>H>>W){
    if(H==0&&W==0) break;
    char space[H][W],c;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> space[j][i];
      }
    }
    x = y = 0;
    while(1){
      c = space[x][y];
      space[x][y] = '0';
      if(c=='>') x++;
      else if(c=='<') x--;
      else if(c=='v') y++;
      else if(c=='^') y--;
      else if(c=='.'){
	cout << x << ' ' << y << endl;
	break;
      }
      else if(c=='0'){
	cout << "LOOP" << endl;
	break;
      }
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int h, w;
char field[100][101];

void solve(int x, int y){

    switch(field[y][x]){

        case '>':
            field[y][x] = 'x';
            solve(x + 1, y);
            return;

        case '<':
            field[y][x] = 'x';
            solve(x - 1, y);
            return;

        case '^':
            field[y][x] = 'x';
            solve(x, y - 1);
            return;

        case 'v':
            field[y][x] = 'x';
            solve(x, y + 1);
            return;

        case '.':
            cout << x << ' ' << y << endl;
            return;

        case 'x':
            cout << "LOOP" << endl;
            return;

    }

}

int main(){

    while(cin >> h >> w, h | w){

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

        solve(0, 0);

    }

}

C++: #include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int *array1, *array2, n, m, tmp, i, j;
	char w;
	
	while(1){
		cin >> n >> m;
		if(n == 0 || m == 0){
			break;
		}
		if(n*m > 2){
			array1 = (int *)calloc(n*m, sizeof(int));
			array2 = (int *)calloc(n*m, sizeof(int));
		} else {
			array1 = (int *)calloc(2, sizeof(int));
			array2 = (int *)calloc(2, sizeof(int));
		}
		
		
		for(i = 0; i < n; i++){
			for(j = 0, tmp = i*m; j < m; j++){
				cin >> w;
				
				if(w == '>'){
					array1[tmp+j] = tmp + j + 1;
				} else if(w == 'v'){
					array1[tmp+j] = tmp + j + m;
				} else if(w == '<'){
					array1[tmp+j] = tmp + j -1;
				} else if(w == '^'){
					array1[tmp+j] = tmp + j - m;
				} else {
					array1[tmp+j] = -1;
				}
			}
		}
		
		tmp = array1[0];
		array2[0] = 1;
		while(1){
			if(array2[tmp] == 1){
				cout << "LOOP" << endl;
				break;
			} else if(array1[tmp] == -1){
				i = tmp % m;
				j = (int)(tmp / m);
				cout << i << " " << j << endl;
				break;
			}
			
			array2[tmp] = 1;
			tmp = array1[tmp];
		}		
		
		free(array1);
		free(array2);
	}
	
	
	return 0;
}