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<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
void field(void);
void move(void);
void clear(void);

  int w,h;
  char mass[103][103]={'\0'};
char now;

int main(){

  while(1){

    scanf("%d %d",&h,&w);

    if(w==h && h==0){
      break;
    }

    field();
    move();
    clear();

  }

  return 0;
}

void field(){

  int i,j;
  
  for(i=0;i<h;i++){
    scanf("%s",mass[i]);
  }

}

void move(){

  now=mass[0][0];
  int end=1,fw=0,fh=0,cnt=0;

  while(end){

    if(cnt==w*h){
      printf("LOOP\n");
      end=0;
    }

    else if(now=='.'){
      printf("%d %d\n",fw,fh);
      end=0;
    }

    else if(now=='>'){
      fw++;
    }

    else if(now=='v'){
      fh++;
    }

    else if(now=='^'){
      fh--;
    }

    else if(now=='<'){
      fw--;
    }

    now=mass[fh][fw];
    cnt++;

  }

}

void clear(){

  int i,j;

  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      mass[i][j]='\0';
    }
  }

}

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

int main() {
  int mapx, mapy;
  int x, y, tmp0 = 0, tmp1 = 0, tmp2 = 0;
  char map[150][150] = {0}, map0[150][150] = {0}, tmpc = 1;
  scanf("%d%d", &mapx, &mapy);
  while (mapx+mapy) {
    while (tmp0 < mapx) {
      scanf("%s", &map[tmp0]);
      tmp0++;
    }
    tmp0 = 0, tmp1 = 0, tmp2 = 0, tmpc = 1;
    x = 0, y = 0;
    while (tmpc && tmpc != 100) {
      map0[x][y]=1;
      if (map[x][y] == '>') y++;
      else if (map[x][y] == '<') y--;
      else if (map[x][y] == '^') x--;
      else if (map[x][y] == 'v') x++;
      else if (map[x][y] == '.') tmpc = 0;
      if (map0[x][y] && tmpc) tmpc = 100;
      tmp2++;
    }
    if (tmpc == 100) puts("LOOP");
    else printf("%d %d\n", (x+1), (y+1));
    scanf("%d%d", &mapx, &mapy);
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int w,h;
	while(cin>>h>>w,h) 
	{
		string f[h];
		for(int i = 0; i < h; ++i)
		{
			cin>>f[i];
		}

		bool used[h][w];
		memset(used,0,sizeof(used));

		int x=0,y=0;
		while(1) 
		{
			if(used[y][x])
			{
				cout<<"LOOP"<<endl;
				break;
			}
			if(f[y][x]=='.')
			{
				cout<<x<<" "<<y<<endl;
				break;
			}
			used[y][x]=true;

			if(f[y][x]=='>') x+=1;
			if(f[y][x]=='<') x-=1;
			if(f[y][x]=='^') y-=1;
			if(f[y][x]=='v') y+=1;
		}
	}
  return 0;
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

typedef map<int, pair<int, long long> > mipill;

int main()
{
	int w, h;
	while(scanf("%d%d", &h, &w), w){
		vector<vector<bool> > memo(h, vector<bool>(w, false));
		vector<string> field(h);
		rep(i, h){
			char str[128];
			scanf("%s", str);
			field[i] = string(str);
		}

		int y = 0, x = 0;
		while(field[y][x] != '.' && !memo[y][x]){
			memo[y][x] = true;
			if(field[y][x] == '>')
				++x;
			else if(field[y][x] == 'v')
				++y;
			else if(field[y][x] == '^')
				--y;
			else
				--x;
		}

		if(field[y][x] == '.')
			printf("%d %d\n", x, y);
		else
			puts("LOOP");
	}

	return 0;
}

C++: #include<stdio.h>
#include<string.h>

int main(){
	char ss[2][110][111];
	int w,h,i,x,y,loop;
	
	while(~scanf("%d%d",&w,&h)){
		if(w==0 && h==0)break;
		
		memset(ss,0,sizeof(ss));
		
		for(i=0;i<w;i++){
			scanf(" %s ",ss[0][i]);
		}
		
		x=0;
		y=0;
		loop=0;
		ss[1][y][x]=1;
		while(1){
			switch(ss[0][y][x]){
			case '>':
				++x;
				loop=ss[1][y][x];
				ss[1][y][x]=1;
				break;
			case '<':
				--x;
				loop=ss[1][y][x];
				ss[1][y][x]=1;
				break;
			case '^':
				--y;
				loop=ss[1][y][x];
				ss[1][y][x]=1;
				break;
			case 'v':
				++y;
				loop=ss[1][y][x];
				ss[1][y][x]=1;
				break;
			}
			
			if(loop)break;
			if(ss[0][y][x]=='.')break;
		}
		
		if(loop==1){
			printf("LOOP\n");
		}else{
			printf("%d %d\n",x,y);
		}
	}
	return 0;
}

C++: #include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

string fie[30]={};


int main(){
    int h,w;
    while(cin>>h>>w){
        if(w==0 && h==0)break;

        rep(i,h){
            cin>>fie[i];
        }

        int y=0,x=0;

        int c=0;
        while(c<1000000){
            c++;
            char ch = fie[y][x];
            if(ch=='>'){
                x++;
            }else if(ch=='<'){
                x--;
            }else if(ch=='^'){
                y--;
            }else if(ch=='v'){
                y++;
            }else break;
        }
        if(c==1000000)cout<<"LOOP"<<endl;
        else cout<<x<<" "<<y<<endl;
    }
}

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];
      for(int i=0;i<h;i++)
	{
	  for(int j=0;j<w;j++)
	    {
	      cin>>str[i][j];
	    }
	}
      int i=0,j=0;
      int looper[h][w];
      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>

int main(int argc, char **argv)
{
	int h, w;
	int x = 0, y = 0;
	char tiles[100][100];
	bool throughed[100][100] = {};
	bool loop = false;
	bool end = false;
	while(std::cin >> h >> w, h+w != 0){
		x = 0;
		y = 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				throughed[j][i] = false;
			}
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				std::cin >> tiles[j][i];
			}
		}
		while(true){
			if(throughed[x][y]){
				loop = true;
				break;
			}
			throughed[x][y] = true;
			switch(tiles[x][y]){
				case '.':
					end = true;
					break;
				case '^':
					y--;
					break;
				case 'v':
					y++;
					break;
				case '<':
					x--;
					break;
				case '>':
					x++;
					break;
			}
			if(end){
				break;
			}
		}
		if(loop){
			std::cout << "LOOP" << std::endl;
		}else{
			std::cout << x << " " << y << std::endl;
		}
	}
	return 0;
}