Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		l := strings.Split(stdin.Text(), " ")
		if l[0] == "0" {
			break
		}
		h, _ := strconv.Atoi(l[0])
		w, _ := strconv.Atoi(l[1])

		tile := make([][]rune, h)
		done := make([][]bool, h)
		for i := 0; i < h; i++ {
			stdin.Scan()
			s := stdin.Text()
			tile[i] = make([]rune, w)
			done[i] = make([]bool, w)
			for j, c := range s {
				tile[i][j] = c
			}
		}
		i, j := 0, 0
		for tile[i][j] != '.' {
			if done[i][j] {
				i = -1
				break
			}
			done[i][j] = true
			switch tile[i][j] {
			case '>':
				j++
			case '<':
				j--
			case '^':
				i--
			case 'v':
				i++
			}
		}
		if i < 0 {
			fmt.Println("LOOP")
		} else {
			fmt.Println(j, i)
		}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int h,w;
  while(cin>>h>>w,h+w) {
    char ba[w][h];
    REP(y,h) {
      REP(x,w) {
        cin >> ba[x][y];
      }
    }
    int x = 0, y = 0;
    int dx[] = {0,1,0,-1};
    int dy[] = {-1,0,1,0};
    char aa[] = {'^','>','v','<'};
    map<char,int> hoge;
    REP(i,4)
      hoge[aa[i]] = i;
    int f[w][h];
    memset(f,0,sizeof(f));
    while(true) {
     
      if (f[x][y]) break;
      if (ba[x][y] == '.') break;

      f[x][y]=1;
      int aa = hoge[ba[x][y]];
      x += dx[aa];
      y += dy[aa];
    }
    if (f[x][y]) cout << "LOOP" << endl;
    else cout << x << " " << y << endl;
  }
}

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

int main(void) {
  int H, W;
  while (cin >> H >> W, H || W) {
    vector<vector<char> > tiles(H, vector<char>(W));

    for (auto i = 0; i < H; i++) {
      for (auto j = 0; j < W; j++) {
        cin >> tiles[i][j];
      }
    }

    bool flag = true;
    int nowX = 0, nowY = 0;
    int max_num = H * W + 1;
    while (flag && max_num--) {
      switch(tiles[nowY][nowX]) {
      case '>':
        nowX++;
        break;
      case '<':
        nowX--;
        break;
      case '^':
        nowY--;
        break;
      case 'v':
        nowY++;
        break;
      default:
        flag = false;
        break;
      }
    }

    if (max_num > 0) {
      cout << nowX << " " << nowY << endl;
    } else {
      cout << "LOOP" << endl;
    }
  }
  return 0;
}

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

int main(int argc, char const* argv[])
{
	unsigned h{}, w{};
	while (std::cin >> h >> w, h != 0) {
		std::vector<char> tiles{};
		std::vector<bool> walked{};
		auto mapsize = h * w;
		tiles.reserve(mapsize);
		walked.assign(mapsize, false);
		for (int i = 0; i < mapsize; i++) {
			char c;
			std::cin >> c;
			tiles.push_back(c);
		}
		//walk
		unsigned current{};
		bool end{false}, loop{false};
		while ( !(end || loop) ) {
			switch (tiles.at(current)) {
				case '>':
					current += 1;
					break;
				case '<':
					current -= 1;
					break;
				case 'v':
					current += w;
					break;
				case '^':
					current -= w;
					break;
				case '.':
					end = true;
					break;
				default:
					break;
			}
			if (walked.at(current) && !end) {
				loop = true;
				break;
			}
			walked.at(current) = true;
		}
		if (loop) {
			std::cout << "LOOP" << std::endl;
		} else {
			auto x = current % w;
			auto y = current / w;
			std::cout << x << ' ' << y << std::endl;
		}
	}


	return 0;
}

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


int main()
{
	int w,k,hyou[101][101],i,j,checki[101],check[101],l=0;
	memset(check,0,100*sizeof(int));
	char a;
	while(1)
	{
		scanf("%d%d",&w,&k);
		if(w==0)
			break;
		scanf("%c",&a);
		for(i=0;i<w;i++){
			for(j=0;j<=k;j++){
				scanf("%c",&a);
				if(a=='>')
					hyou[i][j]=1;
				else	if(a=='<')
					hyou[i][j]=2;
				else if(a=='v')
					hyou[i][j]=3;
				else if(a=='^')
					hyou[i][j]=4;
				else if(a=='.')
					hyou[i][j]=0;
				else 
					hyou[i][j]=6;
			}
		}
		/*for(i=0;i<w;i++){
			for(j=0;j<=k;j++){
				if(hyou[i][j]==6)
				printf("\n");
				else
					printf("%d",hyou[i][j]);
			}
		}*/
		i=0;
		j=0;
		while(hyou[i][j]!=5&&hyou[i][j]!=0){
			switch(hyou[i][j]){
			case 1:
				hyou[i][j]=5;
				j++;
				break;
			case 2:
				hyou[i][j]=5;
				j--;
				break;
			case 3:
				hyou[i][j]=5;
				i++;
				break;
			case 4:
				hyou[i][j]=5;
				i--;
				break;
			case 0:
				check[l]=i;
				checki[l]=j;
				break;
			case 5:
				check[l]=0;
				break;
			}
		}
		if(hyou[i][j]==0){
			check[l]=i;
			checki[l]=j;
		}
		if(hyou[i][j]==5)
			check[l]=-1;
		l++;
	}
	for(i=0;i<l;i++){
		if(check[i]==-1)
			printf("LOOP\n");
		else
			printf("%d %d\n",checki[i],check[i]);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
	for(int w,h;cin>>w>>h;){
		if(w==0&&h==0)break;
		vector<string> v;
		set<int> visited;
		for(int i=0;i<h;++i){
			string s;
			cin>>s;
			v.push_back(s);
		}
		for(int x=0,y=0;;){
			if(visited.find(y*w+x)!=visited.end()){
				cout<<"LOOP\n";
				break;
			}
			visited.insert(y*w+x);
			if(v[y][x]=='.'){
				cout<<x<<" "<<y<<"\n";
				break;
			}else if(v[y][x]=='>')++x;
			else if(v[y][x]=='<')--x;
			else if(v[y][x]=='v')++y;
			else if(v[y][x]=='^')--y;
		}
	}
}

C++: #include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int h,w;
string ss[100];
bool x[100][100];
int ans1=0,ans2=0;
bool ans=true;
bool f(){
	while(true){
		if(ss[ans1][ans2]=='.')return true;
		else if(!x[ans1][ans2])return false;
		else if(ss[ans1][ans2]=='>'){
			x[ans1][ans2]=false;
			ans2++;
			f();
		}
		else if(ss[ans1][ans2]=='<'){
			x[ans1][ans2]=false;
			ans2--;
			f();
		}
		else if(ss[ans1][ans2]=='v'){
			x[ans1][ans2]=false;
			ans1++;
			f();
		}
		else{
			x[ans1][ans2]=false;
			ans1--;
			f();
		}
	}
}
int main()
{
	while(true){
		scanf("%d%d",&h,&w);
		if(h==0&&w==0)return 0;
		for(int i=0;i<h;i++)cin >> ss[i];
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)x[i][j]=true;
		ans1=0,ans2=0;
		ans=true;

		if(f()){
		    cout << ans2 << " " << ans1 << "\n";
		}
		else cout << "LOOP" << "\n";
	}
	return 0;
}

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

#define RIGHT '>'
#define LEFT '<'
#define TOP '^'
#define UNDER 'v'
#define END '.'
#define LOOP 'l'
#define MAX 101

void dfs(char mp[MAX][MAX],int i,int j){
    if(mp[i][j] == END){
        cout << i << ' ' << j << endl;
        return;
    }
    if(mp[i][j] == LOOP){
        cout << "LOOP" << endl;
        return ;
    }
    mp[i][j] = LOOP;
    if(mp[i][j] == RIGHT) dfs(mp,i,j+1);
    else if(mp[i][j] == LEFT) dfs(mp,i,j-1);
    else if(mp[i][j] == TOP) dfs(mp,i-1,j);
    else if(mp[i][j] == UNDER) dfs(mp,i+1,j);
}

int main(){
    char mp[MAX][MAX];
    int n,m;
    
    while(true){
        cin >> n >> m;
        if(!n&&!m) break;
        
        for(int i = 0 ; i < n ; i++)
            for(int j = 0 ; j < m ; j++)
                cin >> mp[i][j];
        
        dfs(mp,0,0);
    }
    
    return 0;
}