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++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int w, h;

    while (cin >> h >> w, h)
    {
        char a[h][w];
        rep(i, h)
        {
            rep(j, w)
            {
                cin >> a[i][j];
            }
        }
        int x = 0, y = 0;
        bool flag = 0;
        rep(i, 10001)
        {
            if (a[y][x] == '<')
                x--;
            else if (a[y][x] == '>')
                x++;
            else if (a[y][x] == '^')
                y--;
            else if (a[y][x] == 'v')
                y++;
            else
            {
                flag = 1;
                break;
            }
        }

        if (flag == 1)
            cout << x << " " << y << endl;
        else
            OP("LOOP");
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<memory.h>
using namespace std;
int main()
{
	while (1){
		char map[101][101];
		bool flag[101][101];
		bool f = false;
		
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0){
			return 0;
		}
		memset(flag, 0, sizeof(flag));
		for (int i = 0; i < h; i++){
			for (int i2 = 0; i2 < w; i2++){
				cin >> map[i][i2];
			}
		}
		int x, y;
		x = 0; y = 0;
		while (map[y][x] != '.'){
			if (flag[y][x] == true){
				cout << "LOOP" << endl;
				f = true;
				break;
			}
			if (map[y][x] == '>'){
				flag[y][x] = true;
				x++;
			}
			else if (map[y][x] == '<'){
				flag[y][x] = true;
				x--;
			}
			else if (map[y][x] == '^'){
				flag[y][x] = true;
				y--;
			}
			else if (map[y][x] == 'v'){
				flag[y][x] = true;
				y++;
			}

		}
		if (!f){
			cout << x << " " << y << endl;
		}
	}
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define SENTINEL INT_MAX
using namespace std;

void solve(int H, int W) {
  vector<string> table;
  set<pair<int, int>> prevs;
  string temp;
  rep(i, H){
    cin >> temp;
    table.push_back(temp);
  }
  auto x = 0;
  auto y = 0;
  while(table[y][x] != '.') {
    if (prevs.count(make_pair(x, y))) {
      cout << "LOOP" <<endl;
      return;
    } else {
      prevs.insert(make_pair(x, y));
    }
    if (table[y][x] == '>') {
      ++x;
    } else if (table[y][x] == 'v') {
      ++y;
    } else if (table[y][x] == '^') {
      --y;
    } else if (table[y][x] == '<') {
      --x;
    }
  }
  cout << x << " " << y << endl;
  return;
}

int main() {
  int H, W;
  while(true) {
    cin >> H >> W;
    if (H == 0 && W == 0) {
      break;
    } else {
      solve(H, W);
    }
  }

}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    int count=0;
    int loopcheck=0;
    char c;
    while (cin>>a>>b) {
        if (a==0&&b==0) {
            break;
        } else {
            std::vector<vector<char>> vec(a,vector<char>(b));
            for (int i=0;i<a;i++) {
                for (int j=0;j<b;j++) {
                    cin>>c;
                    vec[i][j]=c;
                }
            }
            int tate=0;
            int yoko=0;
            while (vec[tate][yoko]!='.') {
                if (vec[tate][yoko]=='>') {
                    yoko++;
                    count++;
                } else if (vec[tate][yoko]=='<') {
                    yoko--;
                    count++;
                } else if (vec[tate][yoko]=='^') {
                    tate--;
                    count++;
                } else if (vec[tate][yoko=='v']) {
                    tate++;
                    count++;
                }
                if (count>a*b) {
                    cout<<"LOOP"<<endl;
                    loopcheck=1;
                    break;
                }
            }
            if (loopcheck!=1) {
                cout<<yoko<<" "<<tate<<endl;
                tate=0;
                yoko=0;
            }
            loopcheck=0;
            count=0;
        }
    }
}

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

using namespace std;

char f[101][101];
int judge[101][101];
int ex, ey;

void move(int i, int j)
{
	//printf("%3d:%3d\n", i, j);
	if(judge[i][j] == 1)
	{
		ex = -1; ey = -1;
		return;
	}
	else if(f[i][j] == '.')
	{
		ex = j; ey = i;
		returan;
	}

	judge[i][j] = 1;

	if(f[i][j] == '>')
	{
		move(i, j+1);
	}
	else if(f[i][j] == '<')
	{
		move(i, j-1);
	}
	else if(f[i][j] == '^')
	{
		move(i-1, j);
	}
	else if(f[i][j] == 'v')
	{
		move(i+1, j);
	}

}

int main()
{
	int w, h;
	while(cin >> h >> w)
	{
		if(h == 0 && w == 0) break;
		for(int i = 0; i < h; i++)
		{
			cin >> f[i];
		}
		/*
		   for(int i = 0; i < h; i++)
		   {
		   for(int j = 0; j < w; j++)
		   {
		   cout << f[i][j];
		   }
		   cout << endl;
		   }
		   */
		//cout << "Run" << endl;
		move(0, 0);
		//cout << "Finish" << endl;

		if(ex == -1 && ey == -1)
		{
			cout << "LOOP" << endl;
		}
		else
		{
			cout << ex << ' ' << ey << endl;
		}
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

int h, w;
char field[100][101];

void solve(int x, int y){

    switch(field[y][x]){

        case '>':
            field[y][x] = 'x';
            solve(x + 1, y);
            return;

        case '<':
            field[y][x] = 'x';
            solve(x - 1, y);
            return;

        case '^':
            field[y][x] = 'x';
            solve(x, y - 1);
            return;

        case 'v':
            field[y][x] = 'x';
            solve(x, y + 1);
            return;

        case '.':
            cout << x << ' ' << y << endl;
            return;

        case 'x':
            cout << "LOOP" << endl;
            return;

    }

}

int main(){

    cin >> h >> w;

    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
            cin >> field[i][j];

    solve(0, 0);

}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int H, W;
	while (cin >> H >> W , H) {
		string b[101];
		for (int i = 0; i < H; i++) {
			cin >> b[i];
		}

		bool visited[101][101] = {false};
		int x = 0, y = 0;
		while (b[y][x] != '.' && !visited[y][x]) {
			visited[y][x] = true;
			if (b[y][x] == '^') y--;
			if (b[y][x] == 'v') y++;
			if (b[y][x] == '<') x--;
			if (b[y][x] == '>') x++;
		}

		if (visited[y][x]) {
			cout << "LOOP" << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}
}