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(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--;
	    }
	  looper[i][j]++;
	  if(str[i][j]=='.')
	    {
	      cout<<j<<" "<<i<<endl;
	      break;
	    }
	  else if(looper[i][j]==1)
	    {
	      cout<<"LOOP"<<endl;
	      break;
	    }
	  
	  
	}
 
    }
        return 0;
}

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

using namespace std;

int main(){
	int w, h;
	char room[100][100];
	vector< pair<int, int> > visited;
	while(cin >> h >> w, h || w){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> room[i][j];
			}
		}
		visited.push_back(pair<int, int>(0, 0));
		int flag = 1;
		while (flag){
			pair<int, int> tmp;
			switch (room[visited.back().first][visited.back().second])
			{
			case '>':
				tmp.first = visited.back().first;
				tmp.second = visited.back().second + 1;
				visited.push_back(tmp);
				break;
			case '<':
				tmp.first = visited.back().first;
				tmp.second = visited.back().second - 1;
				visited.push_back(tmp);
				break;
			case '^':
				tmp.first = visited.back().first - 1;
				tmp.second = visited.back().second;
				visited.push_back(tmp);
				break;
			case 'v':
				tmp.first = visited.back().first + 1;
				tmp.second = visited.back().second;
				visited.push_back(tmp);
				break;
			case '.':
				cout << visited.back().second << ' ' << visited.back().first << endl;
				flag = 0;
				visited.clear();
				break;
			}
			for (int i = visited.size() - 2; i >= 0; i--){
				if (visited[i] == tmp){
					cout << "LOOP" << endl;
					flag = 0;
					break;
				}
			}
		}
	}
	return 0;
}

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

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

int dx, dy;
int main()
{
  int h, w;

  while (cin >> h >> w, h + w){
    string tile[101];
    bool done[101][101], flag = false;

    REP(i, h){
      REP(j, w) done[i][j] = false;
    }
    REP(i, h) cin >> tile[i];
    while (tile[dy][dx] != '.'){
      if (done[dy][dx]){
        flag = true;
        cout << "LOOP" << endl;
        break;
      }
      done[dy][dx] = true;
      if (tile[dy][dx] == '<') dx--;
      if (tile[dy][dx] == '>') dx++;
      if (tile[dy][dx] == '^') dy--;
      if (tile[dy][dx] == 'v') dy++;
    }
    if (flag) continue;
    cout << dx << " " << dy << endl;
  }
}

C++: #include <stdio.h>
#include <queue>
using namespace std;
typedef pair<int,int> P;

int main()
{
	int x,y;
	char map[100][101];
	bool visited[100][100];
	char mapkind[5] = {"><^v"};
	int tx[4] = {1,-1,0,0},ty[4] = {0,0,-1,1};
	queue<P> que;
	P now;

	scanf("%d%d",&y,&x);

	while(x != 0 && y != 0){
		for(int i = 0; i < y; i++){
			for(int j = 0; j < x; j++){
				visited[i][j] = false;
			}
		}
		for(int i = 0; i < y; i++){
			scanf("%s",map[i]);
		}

		now.first = 0; now.second = 0;
		que.push(now);

		while(!que.empty()){
			now = que.front();
			for(int i = 0; i < 4; i++){
				if(map[now.second][now.first] == mapkind[i]){
					if(!visited[now.second + ty[i]][now.first + tx[i]] ){
						visited[now.second + ty[i]][now.first + tx[i]] = true;
						now.second += ty[i];
						now.first += tx[i];
						que.push(now);
						break;
					}
				}
			}
			que.pop();
		}

		if(map[now.second][now.first] == '.'){
			printf("%d %d\n",now.first,now.second);
		}
		else{
			printf("LOOP\n");
		}

		scanf("%d%d",&y,&x);
	}
	
	
	return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main() {
	map<char, int>mp;
	mp['<'] = 0;
	mp['v'] = 1;
	mp['>'] = 2;
	mp['^'] = 3;
	mp['.'] = 4;
	while (1) {
		int H, W; cin >> H >> W;
		if (!H)break;
		vector<vector<int>>field(H, vector<int>(W));
		for (int i = 0; i < H; ++i) {
			string st; cin >> st;
			for (int j = 0; j < W; ++j) {
				field[i][j] = mp[st[j]];
			}
		}
		int nx = 0;
		int ny = 0;
		for (int i = 0; i < 10000; ++i) {
			if (i == 9999) {
				nx = -1;
				break;
			}
			if (field[ny][nx] == 4) {
				break;
			}
			else {
				nx += dx[field[ny][nx]];
				ny += dy[field[ny][nx]];
			}
		}
		if (nx == -1) {
			cout << "LOOP" << endl;
		}
		else {
			cout << nx << " " << ny << endl;
		}
	}
	
	return 0;
}

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

char floor[100][101];
bool visited[100][100];

int main() {
	int w, h;
	while (cin >> h >> w, h||w) {
		for (int j = 0; j < h; j++) {
			cin >> floor[j];
			for (int i = 0; i < w; i++)
				visited[j][i] = false;
		}

		int x = 0, y = 0;
		while (floor[y][x] != '.' && !visited[y][x]) {
			visited[y][x] = true;
			switch (floor[y][x]) {
				case '>': x++; break;
				case '<': x--; break;
				case 'v': y++; break;
				case '^': y--; break;
			}
		}

		if (visited[y][x])
			cout << "LOOP" << endl;
		else
			cout << x << " " << y << 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]=='>')
	{
		map[x][y]='1';
		serch(x,y+1);
	}
	else if(map[x][y]=='<')
	{
		map[x][y]='1';
		serch(x,y-1);
	}
	else if(map[x][y]=='v')
	{
		map[x][y]='1';
		serch(x+1,y);
	}
	else if(map[x][y]=='^')
	{
		map[x][y]='1';
		serch(x-1,y);
	}
	return ;
}

int main()
{
	int w,h;
	int i,j;
	
	for(;;)
	{
		loop=0;
		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;
	}
}