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>

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;
  }
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <map>
using namespace std;
int main (int argc, char *argv[]) {
	int H,W;
	while (true) {
		cin >> H >> W;
		cin.ignore();
		if (H == 0 && W == 0) break;
		vector<string> map(H);
   	for (int i=0;i<H;i++) {getline(cin,map[i]);}
		vector<vector<bool> > flags(H,vector<bool>(W,false));
		queue<pair<int,int> > que;
		que.push(make_pair(0,0));
		while (!que.empty()) {
			pair<int,int> p = que.front(); que.pop();
			int x = p.first, y = p.second;
			if (flags[y][x]) {
				cout << "LOOP" << endl;
				break;
			}
			flags[y][x] = true;
			char d = map[y][x];
			if (d == '>') que.push(make_pair(x+1,y));
			else if (d == '<') que.push(make_pair(x-1,y));
			else if (d == '^') que.push(make_pair(x,y-1));
			else if (d == 'v') que.push(make_pair(x,y+1));
			else if (d == '.') {
				cout << x << " " << y << endl;
				break;
			}
		}
		
	}
	
	return 0;
}

C++: #include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int *array1, *array2, n, m, tmp, i, j;
	char w;
	
	while(1){
		cin >> n >> m;
		if(n == 0 || m == 0){
			break;
		}
		if(n*m > 2){
			array1 = (int *)calloc(n*m, sizeof(int));
			array2 = (int *)calloc(n*m, sizeof(int));
		} else {
			array1 = (int *)calloc(2, sizeof(int));
			array2 = (int *)calloc(2, sizeof(int));
		}
		
		
		for(i = 0; i < n; i++){
			for(j = 0, tmp = i*m; j < m; j++){
				cin >> w;
				
				if(w == '>'){
					array1[tmp+j] = tmp + j + 1;
				} else if(w == 'v'){
					array1[tmp+j] = tmp + j + m;
				} else if(w == '<'){
					array1[tmp+j] = tmp + j -1;
				} else if(w == '^'){
					array1[tmp+j] = tmp + j - m;
				} else {
					array1[tmp+j] = -1;
				}
			}
		}
		
		tmp = array1[0];
		array2[0] = 1;
		while(1){
			if(array2[tmp] == 1){
				cout << "LOOP" << endl;
				break;
			} else if(array1[tmp] == -1){
				i = tmp % m;
				j = (int)(tmp / m);
				cout << i << " " << j << endl;
				break;
			}
			
			array2[tmp] = 1;
			tmp = array1[tmp];
		}		
		
		free(array1);
		free(array2);
	}
	
	
	return 0;
}

C++: #include<stdio.h>


char masu[101][101];
int H,W,x,y;



int main()
{
	int i,j;
	int f,t1,t2;
	char temp;
	
	for(;;){
		x=0;
		y=0;
		f=0;
		
		scanf("%d %d", &H, &W);
		if(H==0)break;
		scanf("%c",&temp);
		
		for(i=0;i<H;i++){
			for(j=0;j<W+1;j++){
				scanf("%c",&masu[i][j]);
			}
		}
		for(;;){
			if(masu[y][x]==','){
				f=1;
				break;
			}
			t1=x;
			t2=y;
			if(masu[y][x]=='>')x++;
			else if(masu[y][x]=='<')x--;
			else if(masu[y][x]=='v')y++;
			else if(masu[y][x]=='^')y--;
			else if(masu[y][x]=='.')break;
			masu[t2][t1]=',';
		}
		if(f==1)puts("LOOP");
		else printf("%d %d\n",x,y);
	}
	return 0;
}