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<cstdio>
#include<memory.h>
using namespace std;
int main()
{
	while (1){
		char map[101][101];
		bool flag[101][101];
		bool f = false;
		
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0){
			return 0;
		}
		memset(flag, 0, sizeof(flag));
		for (int i = 0; i < h; i++){
			for (int i2 = 0; i2 < w; i2++){
				cin >> map[i][i2];
			}
		}
		int x, y;
		x = 0; y = 0;
		if (map[y][x] == '>'){
			x++;
		}
		if (map[y][x] == '<'){
			x--;
		}
		if (map[y][x] == '^'){
			y--;
		}
		if (map[y][x] == 'v'){
			y++;
		}

		while (map[y][x] != '.'){
			if (flag[y][x] == true){
				cout << "LOOP" << endl;
				f = true;
				break;
			}
			if (map[y][x] == '>'){
				flag[y][x] = true;
				x++;
			}
			else if (map[y][x] == '<'){
				flag[y][x] = true;
				x--;
			}
			else if (map[y][x] == '^'){
				flag[y][x] = true;
				y--;
			}
			else if (map[y][x] == 'v'){
				flag[y][x] = true;
				y++;
			}

		}
		if (!f){
			cout << x << " " << y << endl;
		}
	}
}

C++: #include <iostream>

enum struct Panel { none, up, down, right, left };

int main() {
    int h, w;
    while (std::cin >> h >> w && h != 0 && w != 0) {
        std::cin.ignore();

        auto room = new std::pair<Panel, bool>[h * w]();
        std::string s;
        for (int i = 0; i < h; i++) {
            std::getline(std::cin, s);
            for (int j = 0; j < w; j++) {
                switch (s[j]) {
                    case '.': room[i * w + j].first = Panel::none; break;
                    case '^': room[i * w + j].first = Panel::up; break;
                    case 'v': room[i * w + j].first = Panel::down; break;
                    case '>': room[i * w + j].first = Panel::right; break;
                    case '<': room[i * w + j].first = Panel::left; break;
                    default: return EXIT_FAILURE;
                }
            }
        }

        int x = 0, y = 0;
        [&]() {
            while (true) {
                if (room[y * w + x].second) {
                    std::cout << "LOOP";
                    break;
                }
                room[y * w + x].second = true;
                switch (room[y * w + x].first) {
                    case Panel::up: y--; break;
                    case Panel::down: y++; break;
                    case Panel::right: x++; break;
                    case Panel::left: x--; break;
                    case Panel::none: std::cout << x << ' ' << y; return;
                }
            }
        }();
        delete[] room;
        std::cout << std::endl;
    }
}

C++: #include <stdio.h>

int main(){
  while(1){
    int w,h;
    scanf("%d%d", &h, &w);

    if(w==0) break;

    char map[h][w];
    int done[h][w];

    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
       done[i][j] = 0;
       scanf(" %c", &map[i][j]);
       //printf("%c", map[i][j]);
      }
      //puts("");
    }

    int x,y;
    x = y = 0;
    
    while(map[x][y] != '.' && !done[x][y]){
      done[x][y] = 1;
      if(map[x][y] == '>') y++;
      else if(map[x][y] == 'v') x++;
      else if(map[x][y] == '^') x--;
      else if(map[x][y] == '<') y--;
    }

    if(done[x][y]) printf("LOOP\n");
    else printf("%d %d\n", y, x);
  }
  return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,i,j,f,g,c[500][500],v;
	char z[1000][1000],x;
	while(1){
		v=0;
		scanf("%d %d",&a,&s);
		if(a==0&&s==0)	break;
		for(i=0;i<a;i++){
			for(j=0;j<s;j++)
				z[i][j]=0;
		}
		for(i=0;i<a;i++){
			scanf("%s",z[i]);
		}
		for(i=0;i<a;i++){
			for(j=0;j<s;j++){
				c[i][j]=0;
			}
		}
		f=0;
		g=0;
		while(1){
			if(z[f][g]=='>'){
				g++;
				c[f][g]++;
			//	printf("%d %d\n",f,g);
			}
			else if(z[f][g]=='<'){
				g--;
				c[f][g]++;
			//	printf("%d %d\n",f,g);
			}
			else if(z[f][g]=='^'){
				f--;
				c[f][g]++;
			//	printf("%d %d\n",f,g);
			}
			else if(z[f][g]=='v'){
				f++;
				c[f][g]++;	
			//	printf("%d %d\n",f,g);
			}
			if(z[f][g]=='.')	break;
			if(c[f][g]==2){
				v=1;
				break;
			}
		}
		if(v==1)
			printf("LOOP\n");
		else
			printf("%d %d\n",g,f);
	}
		return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
char a[1000][1000]; int h, w, loop, cx, cy;
int main() {
	while (true) {
		cin >> h >> w;
		if (!h) { break; }
		memset(a, ' ', sizeof(a));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> a[i][j];
			}
		}
		cx = 0; cy = 0; loop = 0;
		while (true) {
			if (loop > 10000000) { cout << "LOOP" << endl; break; }
			if (a[cy][cx] == '.') { cout << cx << ' ' << cy << endl; break; }
			if (a[cy][cx] == '<') { cx--; }
			if (a[cy][cx] == '>') { cx++; }
			if (a[cy][cx] == '^') { cy--; }
			if (a[cy][cx] == 'v') { cx++; }
			loop++;
		}
	}
}

C++: //51
#include<iostream>

using namespace std;

int main(){
  for(int W,H;cin>>H>>W,W|H;){
    char g[100][100];
    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
	cin>>g[y][x];
      }
    }
    int y=0,x=0;
    while(g[y][x]!='.'&&g[y][x]!='\0'){
      int ny=y+(g[y][x]=='v')-(g[y][x]=='^');
      int nx=x+(g[y][x]=='>')-(g[y][x]=='<');
      g[y][x]='\0';
      y=ny;
      x=nx;
    }
    if(g[y][x]){
      cout<<x<<' '<<y<<endl;
    }else{
      cout<<"LOOP"<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int h, w;
	char map[101][101];
	
	while (cin >> h >> w, h * w){
		int x = 0, y = 0;
		bool check[101][101];
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> map[i][j];
				check[i][j] = false;
			}
		}
		
		while (map[y][x] != '.'){
			if (check[y][x])	break;
			check[y][x] = true;
			if (map[y][x] == '>')	x++;
			else if (map[y][x] == '<')	x--;
			else if (map[y][x] == '^')	y--;
			else if (map[y][x] == 'v')	y++;
		}
		if (check[y][x])	cout << "LOOP";
		else cout << x << ' ' << y;
		cout << endl;
	}
	return (0);
}

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

int main(void) {
  char G[100][100];
  bool visited[100][100];
  int W, H;
  string str;
  
  while(cin >> W >> H) {
    if(W==0 && H==0) break;
    for(int i=0; i<H; i++) {
      cin >> str;
      for(int j=0; j<W; j++) {
	G[i][j] = str[j];
	visited[i][j] = false;
      }
    }
    
    
    int x=0, y=0;
    while(1) {
      if(visited[y][x]) { cout << "LOOP" << endl; break; }
      
      visited[y][x] = true;
      if(G[y][x] == '>') x++;
      else if(G[y][x] == 'v') y++;
      else if(G[y][x] == '^') y--;
      else if(G[y][x] == '<') x--;
      else if(G[y][x] == '.') { cout << x << " " << y << endl; break; }

    }

  }
  
  return 0;
}