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>
#include <bitset>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int W, H;
	while(cin >> H >> W, W, H)
	{
		bool Flag[128][128];
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				Flag[i][j] = false;
			}
		}
		vector< vector<char> > Field(H);
		for(int i = 0; i < H; ++i)
		{
			Field[i].resize(W);
		}
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				cin >> Field[i][j];
			}
		}
		P Pos(0, 0);
		bool LoopFlag = false;
		while(true)
		{
			if(Flag[Pos.second][Pos.first] == true)
			{
				LoopFlag = true;
				break;
			}
			Flag[Pos.second][Pos.first] = true;
			if(Field[Pos.second][Pos.first] == '>')
			{
				++Pos.first;
			}
			else if(Field[Pos.second][Pos.first] == '<')
			{
				--Pos.first;
			}
			else if(Field[Pos.second][Pos.first] == '^')
			{
				--Pos.second;
			}
			else if(Field[Pos.second][Pos.first] == 'v')
			{
				++Pos.second;
			}
			else if(Field[Pos.second][Pos.first] == '.')
			{
				break;
			}
		}
		if(!LoopFlag)
		{
			cout << Pos.first << " " << Pos.second << endl;
		}
		else
		{
			cout << "LOOP" << endl;
		}
	}
}

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

C++: #include<stdio.h>
char c[100][100];
int main(){
	int a;
	int b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)
			for(int j=0;j<b;j++)
				scanf(" %c",&c[i][j]);
		
		int s=0;
		int t=0;
		while(1){
			switch(c[s][t]){
				case '>':
					c[s][t]='x';
					t++;
					break;
				case '<':
					c[s][t]='x';
					t--;
					break;
				case 'v':
					c[s][t]='x';
					s++;
					break;
				case '^':
					c[s][t]='x';
					s--;
					break;
			}
			if(c[s][t]=='x')break;
			if(c[s][t]=='.')break;
		}
		if(c[s][t]=='x')printf("LOOP\n");
		else printf("%d %d\n",t,s);
	}
}

C++: #include <stdio.h>
 
int main(void)
{
    char m[102][102];
 
    while(1)
    {
        int h,w,x,y;
        scanf("%d%d",&h,&w);
        if(h==0&&w==0)return 0;
        for(y=0;y<h;y++)
            scanf("%s",m[y]);
        x=0;y=0;
        for(;;)
        {
            h=m[y][x];m[y][x]='!';
            if(h=='!')
            {
                puts("LOOP");
                break;
            }
            else if(h=='v') y++;
            else if(h=='^') y--;
            else if(h=='>') x++;
            else if(h=='<') x--;
            else
            {
                printf("%d %d\n",x,y);
                break;
            }
        }
    }
    return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
void put(int,int);
int h,w;
int x,y;
int flag=0;
char tile[1111][1111];
int main(){
  while(1){
    cin >> h >> w;
    if(h==0 && w==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> tile[i][j];
      }
    }
    put(0,0);
    if(flag==1){
      cout << y << ' ' << x << endl;
    }
    if(flag==2){
      cout << "LOOP" << endl;
    }
  }
}

void put(int a,int b){
  
  if(tile[a][b]=='.'){
    x=a;
    y=b;
    flag=1;
    return;
  }
  if(tile[a][b]==-1){
    flag=2;
    return;
  }
  if(tile[a][b]=='>'){
    tile[a][b]=-1;
    put(a,b+1);
  }
  if(tile[a][b]=='<'){
    tile[a][b]=-1;
    put(a,b-1);
  }
  if(tile[a][b]=='^'){
    tile[a][b]=-1;
    put(a-1,b);
  }
  if(tile[a][b]=='v'){
    tile[a][b]=-1;
    put(a+1,b);
  }
  return;
}

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

int main(){
	int a,b,field[100][100],x,y,loop;
	char c[100][100];
	while (1){
		loop = 0;
		x = 0;
		y = 0;
		for (int i = 0; i < 100; i++){
			for (int j = 0; j < 100; j++) field[i][j] = 0;
		}
		cin >> a >> b;
		if (!a && !b) break;
		getchar();
		for (int i = 0; i < a; i++){
			for (int j = 0; j < b; j++){
				c[i][j] = getchar();
			}
			getchar();
		}
		while (c[x][y] != '.'){
			if (field[x][y]) {
				loop = 1;
				break;
			}
			field[x][y] = 1;
			if (c[x][y] == '>') y++;
			if (c[x][y] == '^') x--;
			if (c[x][y] == '<') y--;
			if (c[x][y] == 'v') x++;
		}
		if (loop) cout << "LOOP" << endl;
		else cout << y << " " << x << endl;
	}
	return 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>>W>>H;
		if(W==0&&H==0) break;
	
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>tile[j][i];
				flag[j][i]=false;
			}
		}
		
		if((ans=solve(0,0))==-1) cout<<"LOOP"<<endl;
		else cout<<ans/1000<<" "<<ans%1000<<endl;
	}
	
	return 0;
}

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

char board[100][100];
bool hasArrived[100][100];

int main() {
	int h, w;
	while (std::cin >> h >> w, h + w != 0) {
		for (int y = 0; y < h; ++y)
			for (int x = 0; x < w; ++x)
				std::cin >> board[x][y];

		int px = 0, py = 0;
		while (true) {
			if (hasArrived[px][py]) {
				std::cout << "LOOP" << std::endl;
				break;
			}

			hasArrived[px][py] = true;

			if (board[px][py] == '.') {
				std::cout << px << " " << py << std::endl;
				break;
			}
			
			if (board[px][py] == '>')
				++px;
			else if (board[px][py] == '<')
				--px;
			else if (board[px][py] == 'v')
				++py;
			else if (board[px][py] == '^')
				--py;
		}

		std::memset(board, 0, sizeof(board));
	}
}

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;
	}
	else{
		return false;
	}
}
int main(){
	char map[100][100];

	while (cin >> H >> W,W+H){

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