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>
using namespace std;

int main(void) {
  char G[102][102];
  bool visited[102][102];
  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;
}

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

char field[100][100];

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

int main()
{
	int w,h;
	while(cin >> w >> h){
		if(!w && !h)
			break;
		for(int i=0;i<w;i++){
			for(int j=0;j<h;j++){
				cin >> field[i][j];
			}
		}
		search(0,0);
	}
	return 0;
}

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

int main()
{
	vector< vector<char> > tile(101, vector<char>(101));
	int W, H, i, j;
	map<pair<int, int>, int> passed;
	while (cin>>H>>W, H||W) {
		for (j = 0; j < H; j++)
			for (i = 0; i < W; i++)
				cin>>tile[i][j];
		i = 0;
		j = 0;
		passed.clear();
		while (!passed[make_pair(i,j)]) {
			if (tile[i][j]=='.') {
				cout<<i<<" "<<j<<endl;
				break;
			}
			passed[make_pair(i,j)] = 1;
			if (tile[i][j]=='<') i--;
			else if (tile[i][j]=='>') i++;
			else if (tile[i][j]=='^') j--;
			else if (tile[i][j]=='v') j++;
		}
		if (passed[make_pair(i,j)]) cout<<"LOOP"<<endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

char map[110][110];
int s_x,s_y,loop;

void serch(int x,int y)
{
	if(map[x][y]=='1')
	{
		loop=1;
		return ;
	}
	if(map[x][y]=='.')
	{
		s_x=x;
		s_y=y;
		return ;
	}
	if(map[x][y]=='>')
	{
//		cout << "x:" << x << " y:" << y <<" nowmap:" << map[x][y] << endl;
		map[x][y]='1';
		serch(x,y+1);
	}
	else if(map[x][y]=='<')
	{
//		cout << "x:" << x << " y:" << y <<" nowmap:" << map[x][y] << endl;
		map[x][y]='1';
		serch(x,y-1);
	}
	else if(map[x][y]=='v')
	{
//		cout << "x:" << x << " y:" << y <<" nowmap:" << map[x][y] << endl;
		map[x][y]='1';
		serch(x+1,y);
	}
	else if(map[x][y]=='^')
	{
//		cout << "x:" << x << " y:" << y <<" nowmap:" << map[x][y] << endl;
		map[x][y]='1';
		serch(x-1,y);
	}
	return ;
}

int main()
{
	int w,h;
	int i,j;
	
	for(;;)
	{
		cin >> w >> h ;
		if(w==0 && h==0)
			break;
		for(i=0;i<w;i++)
		{
			for(j=0;j<h;j++)
			{
				cin >> map[i][j] ;
			}
		}
		
		serch(0,0);
		
		if(loop==1)
			cout << "LOOP" << endl;
		else
			cout << s_y << " " << s_x << endl;
	}
}

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

C++: #include <iostream>

using namespace std;

int main() {

	int w, h;

	while(cin >> w >> h) {
		if(!w&&!h) {
			break;
		}
		char s[100][100];
		for(int i=0; i<w; i++) {
			for(int j=0; j<h; j++) {
				cin >> s[i][j];
			}
		}
		int c=0, x=0, y=0;
		while(c<w*h) {
			if(s[x][y]=='>') {
				y++;
			}
			else if(s[x][y]=='<') {
				y--;
			}
			else if(s[x][y]=='^') {
				x--;
			}
			else if(s[x][y]=='v') {
				x++;
			}
			else if(s[x][y]=='.') {
				break;
			}
			c++;
		}
		if(c!=w*h) {
			cout << y << " " << x << endl;
		}
		else {
			cout << "LOOP" << endl;
		}
	}

	return 0;

}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int h, w;
        cin >> h >> w;
        if(h == 0)
            return 0;

        vector<string> tile(h);
        for(int i=0; i<h; ++i)
            cin >> tile[i];

        vector<vector<bool> > check(h, vector<bool>(w, false));
        int y = 0;
        int x = 0;
        for(;;){
            char c = tile[y][x];
            if(c == '.'){
                cout << x << ' ' << y << endl;
                break;
            }
            check[y][x] = true;
            if(c == '>')
                ++ x;
            else if(c == '<')
                -- x;
            else if(c == 'v')
                ++ y;
            else
                -- y;
            if(check[y][x]){
                cout << "LOOP" << endl;
                break;
            }
        }
    }
}

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 < 10000; i++)
      //mem[i / 100][i % 100]  = 0;
    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;
  }
}