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

		}
	}
}

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);
  }
  return 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 <iostream>
#include <string>
using namespace std;
string tiles[100];
int main()
{
	int X,Y;
	while(1)
	{
		cin >> Y >> X ;
		if(X==0 && Y==0) break;
		for(int i=0;i<Y;i++) cin >> tiles[i] ;
		bool Loop=false; bool flag[100][100]={false};

		int curr_x=0; int curr_y=0; flag[0][0]=true;
		while(tiles[curr_y][curr_x]!='.')
		{
			if(tiles[curr_y][curr_x]=='>') curr_x++;
			else if(tiles[curr_y][curr_x]=='<') curr_x--;
			else if(tiles[curr_y][curr_x]=='^') curr_y--;
			else if(tiles[curr_y][curr_x]=='v') curr_y++;
			if(flag[curr_y][curr_x]==true) {Loop=true; break;}
			else flag[curr_y][curr_x]=true;
		}
		if(Loop==true) cout << "LOOP" << endl;
		else cout << curr_x << ' ' << curr_y << endl;
	}
}

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

using namespace std;

#define H_MAX 100
#define W_MAX 100

int H, W;

string f[H_MAX];      // field
bool p[H_MAX][W_MAX]; // have passed?

void go(int x, int y) {
    if (p[y][x]) {
        cout << "LOOP\n";
        return;
    }
    p[y][x] = true;
    switch (f[y][x]) {
        case '>':
            go(x+1, y);
            break;
        case '<':
            go(x-1, y);
            break;
        case '^':
            go(x, y-1);
            break;
        case 'v':
            go(x, y+1);
            break;
        default:
            cout << x << ' ' << y << endl;
            break;
    }
}

int main() {
    while (cin >> H >> W) {
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++) {
            cin >> f[i];
            for (int j = 0; j < W; j++) {
                p[i][j] = false;
            }
        }
        go(0, 0);
    }
    return 0;
}

C++: #include <stdio.h>
 
int main() {
 
  char map[101][101],a[102];
  int i,j,w,h,x,y,flag;
 
  while(1) {
    scanf("%d %d",&h,&w);
    if(w==0 && h ==0) break;
 
    for(i=0;i<h;i++) {
      scanf("%s",a);
      for(j=0;j<w;j++) {
    map[i][j] = a[j];
      }
 
    }
 
    flag = 0;
    x  = y = 0;
 
    while(1) {
      flag++;
      if(map[y][x] == '^')y--;
      else if(map[y][x] == '>')x++;
      else if(map[y][x] == 'v')y++;
      else if(map[y][x] == '<')x--;
      else if(map[y][x] == '.'){
    //  printf("break\n");
    break;
      }
       
      // printf("flag = %d\n",flag);
      if(flag >=25000) break;
    }
 
 
    if(flag >= 24000) printf("LOOP\n");
    else printf("%d %d\n",x,y);
 
  }
 
  return 0;
 }

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

char field[101][101];
bool check[101][101];

void tile(int x,int y) {
  if(check[y][x]) {
    check[y][x] = false;
  }
  else {
    cout << "LOOP" << endl;
    return;
  }

  if(field[y][x] == '>') {
    tile(x+1,y);
  }
  else if(field[y][x] == '<') {
    tile(x-1,y);
  }
  else if(field[y][x] == '^') {
    tile(x,y-1);
  }
  else if(field[y][x] == 'v') {
    tile(x,y+1);
  }
  else if(field[y][x] == '.') {
    cout << x << " " << y << endl;
    return;
  }
}

int main() {
  int W,H;
  string str;
  while(cin >> W >> H) {
    if(W==0 && H==0) break;
    getline(cin,str);//kill \n
    for(int i=0;i<W;i++) {
      getline(cin,str);
      for(int j=0;j<H;j++) {
        field[i][j] = *str.substr(j,1).c_str();
        check[i][j] = true;
      }
    }
    tile(0,0);
  }
}

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

char tile[150][150];
bool flag[150][150];

int solve(int x,int y){
	if(flag[x][y]) return -1;
	int ans;
	
	flag[x][y]=true;
	switch(tile[x][y]){
	case '>':
		ans=solve(x+1,y);
		break;
	case '<':
		ans=solve(x-1,y);
		break;
	case 'v':
		ans=solve(x,y+1);
		break;
	case '^':
		ans=solve(x,y-1);
		break;
	case '.':
		ans=x*1000+y;
		break;
	default:
		break;
	}
	return ans;
}

int main(){
	int W,H,ans;

	while(1){
		cin>>H>>W;
		if(W==0&&H==0) break;
	
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				flag[j][i]=false;
			}
		}
		
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>tile[j][i];
			}
		}
		
		if((ans=solve(0,0))==-1) cout<<"LOOP"<<endl;
		else cout<<ans/1000<<" "<<ans%1000<<endl;
	}
	
	return 0;
}