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;
string s[100];
bool used[100][100];
int h,w;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
main()
{
    while(cin>>h>>w,h)
    {
        for(int i=0;i<h;i++)
        {
            cin>>s[i];
            for(int j=0;j<w;j++)used[i][j]=0;
        }
        int x=0,y=0,f=0;
        while(!used[x][y])
        {
            used[x][y]=1;
            if(s[x][y]=='.')
            {
                f=1;
                cout<<y<<" "<<x<<endl;
                break;
            }
            int r=s[x][y]=='>'?0:s[x][y]=='<'?2:s[x][y]=='v'?1:3;
            x+=dx[r],y+=dy[r];
        }
        if(!f)cout<<"LOOP"<<endl;
    }
}

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

int main(){
	int w,h;
	while(cin>>w>>h )
	{
		if(h==0 || w==0)break;
		char mass[102][102];
		bool key[102][102];

		for( int i=0; i<h; i++) {
			for( int j=0; j<w; j++){
				cin>>mass[i][j];
				key[i][j]=false;
			}
		}
		w=0,h=0;
		while(1)
		{
			key[h][w]=true;
			if( mass[h][w] == '>' ) w++;
			else if( mass[h][w] == '<' ) w--;
			else if( mass[h][w] == '^' ) h--;
			else if( mass[h][w] == 'v' ) h++;
			else {
				cout<<w<<" "<<h<<endl;
				break;
			}
			
			if(key[h][w]) {
				puts("LOOP");
				break;
			}
		}
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int H,W,x,y,flag;
char tile[100][101];

int main(){
	while(cin>>H>>W){
		if(H+W==0)return 0;
		for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>tile[i][j];
		x=0;y=0;flag=0;
		for(int i=0;i<10000;i++){
			if(tile[y][x]=='.'){
				cout<<x<<" "<<y<<endl;
				flag=1;
				break;
			}
			if(tile[y][x]=='>')x++;
			if(tile[y][x]=='<')x--;
			if(tile[y][x]=='^')y--;
			if(tile[y][x]=='v')y++;
		}
		if(flag==0)cout<<"LOOP"<<endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
int main( void )
{
	while ( 1 )
	{
		int w, h;
		cin >> h >> w;
		if ( w == 0 && h == 0 )
			break;

		vector <string> data;
		for ( int i = 0; i < h; i++ )
		{
			string line;
			cin >> line;
			data.push_back( line );
		}

		bool loop_flag = false;
		int x = 0;
		int y = 0;
		while ( 1 )
		{
			int oldx = x;
			int oldy = y;
			if ( data[y][x] == '.' )
				break;
			else if ( data[y][x] == '>' )
				x++;
			else if ( data[y][x] == 'v' )
				y++;
			else if ( data[y][x] == '^' )
				y--;
			else if ( data[y][x] == '<' )
				x--;
			else if ( data[y][x] == 'x' )
			{
				loop_flag = true;
				break;
			}
			data[oldy][oldx] = 'x';
		}

		if ( loop_flag )
			cout << "LOOP" << endl;
		else
			cout << x << " " << y << endl;

	}
	return 0;
}

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

using namespace std;

int main(){
	int n,m,k,l,b[105][105]={0};
	char a[105][105];
	while(1){
		scanf("%d %d",&n,&m);
		if( n==0 && m==0 ) break;
		k=0; l=0;
		for(int i=0 ; i<n ; i++ ){
			scanf("%s",&a[i]);	
		}
		while(1){
			if(a[k][l]=='.'){
				printf("%d %d\n",l,k);
				break;
			}
			if(b[k][l]==1){
				printf("LOOP\n");
				break;
			}
			if(a[k][l]=='>'){
				b[k][l]=1;
				l++;
				continue;
			}
			if(a[k][l]=='v'){
				b[k][l]=1;
				k++;
				continue;
			}
			if(a[k][l]=='<' ){
				b[k][l]=1;
				l--;
				continue;
			}
			if(a[k][l]=='^' ){
				b[k][l]=1;
				k--;
				continue;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

void solve105(int H, int W) {
    vector<vector<int>> visited(H, vector<int>(W,0));
    vector<vector<char>> floor(H, vector<char>(W,0));
    string s;
    REP(i,H) {
        cin >> s;
        REP(j,W) {
            floor[i][j] = s[j];
        }
    }
    int x = 0; int y = 0;
    while (floor[y][x] != '.') {
        if (visited[y][x]) {
            cout << "LOOP" << endl;
            return;
        }
        visited[y][x] = 1;
        if (floor[y][x] == '>') {
            x++;
        }else if (floor[y][x] == '<') {
            x--;
        }else if (floor[y][x] == 'v') {
            y++;
        }else {
            y--;
        }
    }
    cout << x << " " << y << endl;
}

int main() {
    int H, W;
    while (cin >> H >> W, H + W) {
        solve105(H, W);
    }
}

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

using namespace std;

int main(){
	int n,m,k,l,b[105][105]={0};
	char a[105][105];
	while(1){
		scanf("%d %d ",&n,&m);
		if( n==0 && m==0 ) break;
		k=0; l=0;
		for(int i=0 ; i<n ; i++ ){
			scanf("%s",&a[i]);	
		}
		while(1){
			if(a[k][l]=='.'){
				printf("%d %d\n",l,k);
				break;
			}
			if(b[k][l]==1){
				printf("LOOP\n");
				break;
			}
			if(a[k][l]=='>'){
				b[k][l]=1;
				l++;
				continue;
			}
			if(a[k][l]=='v'){
				b[k][l]=1;
				k++;
				continue;
			}
			if(a[k][l]=='<' ){
				b[k][l]=1;
				l--;
				continue;
			}
			if(a[k][l]=='^' ){
				b[k][l]=1;
				k--;
				continue;
			}
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int status[102][102];
char field[102][102];
void serch(int h,int w)
{
    if(status[h][w]==1)cout<<"LOOP"<<endl;
    else{
        status[h][w]++;
        if(field[h][w]=='>')serch(h,w+1);
        else if(field[h][w]=='<')serch(h,w-1);
        else if(field[h][w]=='v')serch(h+1,w);
        else if(field[h][w]=='^')serch(h-1,w);
        else cout<<w<<" "<<h<<endl;
    }
}
int main()
{
    int H,W;
    while(cin>>H>>W&&H!=0){
        for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                        status[i][j]=0;
                        cin>>field[i][j];
                }
        }
        serch(0,0);
    }
}

C++: #include <cstdio>

using namespace std;

int main()
{
	int h, w;
	char str[100][100];
	
	while (scanf("%d %d", &h, &w), !(h == 0 && w == 0)){
		bool flag = true;
		
		for (int i = 0; i < h; i++){
			scanf("%s", str[i]);
		}
		int x = 0, y = 0;
		while (str[y][x] != '.'){
			
			if (str[y][x] == 'l'){
				flag = false;
				break;
			}
			if (str[y][x] == '>'){
				str[y][x] = 'l';
				x++;
			}
			else if (str[y][x] == '<'){
				str[y][x] = 'l';
				x--;
			}
			else if (str[y][x] == '^'){
				str[y][x] = 'l';
				y--;
			}
			else if (str[y][x] == 'v'){
				str[y][x] = 'l';
				y++;
			}
		}
		if (flag){
			printf("%d %d\n", x, y);
		}
		else {
			printf("LOOP\n");
		}
	}
}