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>

using namespace std;

int main(){

	int h, w;
	char field[1000][1000];
	bool vis[1000][1000];

	while(cin>>h>>w, (h||w)){
			
		for(int i=0; i<h; ++i){
			for(int j=0; j<w; ++j){
				
				vis[i][j]=false;
				cin>>field[i][j];
			}
		}
		
		int x=0, y=0;
		
		while(!vis[y][x] && field[y][x] != '.'){
			
			vis[y][x] = true;

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

		}
		
		if(vis[y][x]){
			cout << "LOOP" << endl;
		}
		else{
			cout << x << " " << y << endl;
		}
	}

	return 0;
}

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

int main() {
    int X, Y;
    
    while (cin >> X >> Y && X + Y != 0) {
        char room[101][101];
        for (int x = 0; x < X; ++x) {
            for (int y = 0; y < Y; ++y) {
                cin >> room[x][y];
            }
        }

        int steps = 0;
        int x = 0, y = 0;

        while (room[x][y] != '.' && steps < 10000) {
            if (room[x][y] == '>') {
                y++;
            }
            if (room[x][y] == '<') {
                y--;
            }
            if (room[x][y] == '^') {
                x--;
            }
            if (room[x][y] == 'v') {
                x++;
            }
            steps++;
        }

        if (steps >= 10000) {
            cout << "LOOP" << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }
    return 0;
}

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

int main(){

  string str[1000];
  int a,b;

  while(cin >> a >> b, a, b){

    for(int i=0;i<a;i++) cin >> str[i];

    int x = 0,y = 0,count = 0,t = 0;

    while(1){
      if(count == 1000000){
	t = 1;
	break;
      }

      if(str[x][y] == '>') y++;
      else if(str[x][y] == '<') y--;
      else if(str[x][y] == '^') x--;
      else if(str[x][y] == 'v') x++;
      else break;
      count++;
    }

    if(t == 1) cout << "LOOP" << endl;
    else cout << y << " " << x << endl;

  }
}

C++: #include <stdio.h>

int main(void){
	int i, j;
	int x, y;
	int w, h;
	char tile[128][128];
	int tile2[128][128];
	
	while (scanf("%d %d", &h, &w), h != 0 || w != 0){
		for (i = 0; i < h; i++){
			scanf("%s", tile[i]);
			for (j = 0; j < w; j++){
				tile2[i][j] = 0;
			}
		}
		
		x = 0; y = 0;
		while (tile[x][y] != '.' && tile2[x][y] < 2){
			tile2[x][y]++;
			if (tile[x][y] == '^') x--;
			if (tile[x][y] == 'v') x++;
			if (tile[x][y] == '>') y++;
			if (tile[x][y] == '<') y--;
		}
		
		if (tile2[x][y] > 1) printf("LOOP\n");
		else printf("%d %d\n", y, x);
		
	}
	return (0);
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)




int main(void){
	int w,h;
	char map[100][100];
	while(cin >> h >> w,w|h){
		rep(j,h)
			rep(i,w)
				cin >> map[i][j];
		int x=0,y=0;
		while(true){
			if(map[x][y]=='@'){
				cout << "LOOP" << endl;
				break;
			}
			if(map[x][y]=='>'){
				x++;
				map[x-1][y]='@';
			}else if(map[x][y]=='<'){
				x--;
				map[x+1][y]='@';
			}else if(map[x][y]=='v'){
				y++;
				map[x][y-1]='@';
			}else if(map[x][y]=='^'){
				y--;
				map[x][y+1]='@';
			}else{
				cout << x << " " << y << endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	int h,w,x,y;
	char dp[150][150];
	while(true){
	cin>>h>>w;
	if(h==0&&w==0)
		break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>dp[i][j];
		}
	}
	x=0,y=0;
	int i=0;
	bool loop=false;
	while(true){
		if(dp[x][y]=='>')
			y+=1;
		if(dp[x][y]=='<')
			y-=1;
		if(dp[x][y]=='^')
			x-=1;
		if(dp[x][y]=='v')
			x+=1;
		if(dp[x][y]=='.')
			break;
		i++;
		if(i==10100){
			cout<<"LOOP"<<endl;
			loop=true;
		}
	}
	if(loop==false)
	cout<<y<<" "<<x<<endl;
	}
	return 0;
}

C++: #include <stdio.h>
#define U 1
#define D 2
#define R 3
#define L 4
#define MAX 100

int main(void){
    int dx[L+1] = {0,0,0,1,-1};
    int dy[L+1] = {0,-1,1,0,0};
    int pnl[MAX][MAX];
    int visited[MAX][MAX];
    char buf[MAX+1];
    int h,w,x,y,dir;
    
    while (scanf("%d %d",&h, &w)){
        if (h==0 && w==0) break;
        // load
        for (int i=0; i<h; i++){
            scanf("%s", buf);
            for (int j=0; j<w; j++){
                visited[j][i] = pnl[j][i] = 0;
                switch (buf[j]){
                    case '^' : pnl[j][i]=U; break;
                    case 'v' : pnl[j][i]=D; break;
                    case '>' : pnl[j][i]=R; break;
                    case '<' : pnl[j][i]=L; break;
                }
            }
        }
        // move
        x = y = 0;
        while(pnl[x][y] && !visited[x][y]){
            printf("%d %d\n", x,y);
            visited[x][y]=1;
            dir = pnl[x][y];
            x += dx[dir];
            y += dy[dir];
        }
        if (pnl[x][y]){
            printf("LOOP\n");
        } else {
            printf("%d %d\n", x,y);
        }
    }
    
    return 0;
}

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

using namespace std;
bool flag[101][101];
char field[101][101];

void DFS(int y, int x)
{
	if(flag[y][x] == true)
	{
		cout << "LOOP" << endl;
		return;
	}
	flag[y][x] = true;
	if(field[y][x] == '.')
	{
		cout << x << " " << y << endl;
	}
	else if(field[y][x] == '>')
	{
		DFS(y, x + 1);
	}
	else if(field[y][x] == '<')
	{
		DFS(y, x - 1);
	}
	else if(field[y][x] == '^')
	{
		DFS(y - 1, x);
	}
	else if(field[y][x] == 'v')
	{
		DFS(y + 1, x);
	}
}

void solve()
{
	int W, H;
	while(cin >> H >> W, W || H)
	{
		memset(flag, 0, sizeof(flag));
		memset(field, 0, sizeof(field));
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				cin >> field[i][j];
			}
		}
		DFS(0, 0);
	}
}

int main()
{
	solve();
	return(0);
}

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