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>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	int h,w;
	while(cin>>h>>w&&h)
	{
		string a[120];
		for(int i=0;i<h;i++)
		{
			cin>>a[i];
		}
		pair<int,int> p(0,0);
		map< pair<int,int>,int > m;
		m[p]=1;
		bool ok=true;
		while(ok)
		{
			char now=a[p.first][p.second];
			switch(now)
			{
			case '^':
				p.first--;
				break;
			case '>':
				p.second++;
				break;
			case 'v':
				p.first++;
				break;
			case '<':
				p.second--;
				break;
			case '.':
				cout<<p.second<<" "<<p.first<<endl;
				ok=false;
				break;
			}
			if(ok&&m.count(p))
			{
				cout<<"LOOP"<<endl;
				break;
			}
			m[p]=1;
		}
		
	}
	
}

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

#define REP(i, m, n) for(int i = m; i < static_cast<int>(n); ++i)
int main()
{
    int height, width;
    std::vector<std::string> tile = {">", "<", "^", "v", "."};
    
    while (std::cin >> height >> width) {
        if (height == 0 && width == 0) {
            break;
        }
        
        std::vector< std::vector<std::string> > table;
            
        REP(i, 0, height) {
        table.push_back( std::vector<std::string>() );
            
        REP(j, 0, width) {
            std::string data;
            std::cin >> std::setw(1) >> data;
            table[i].push_back(data);
        }
    }
            
        
        bool flag = true;

        while (flag){
            static int i = 0;
            static int j = 0;
            
            if (table[i][j] == tile[0]) {
                table[i][j] = ",";
                j++;
                continue;
            } else if (table[i][j] == tile[1]) {
                table[i][j] = ",";
                j--;
                continue;
            } else if (table[i][j] == tile[2]) {
                table[i][j] = ",";
                i--;
                continue;
            } else if (table[i][j] == tile[3]) {
                table[i][j] = ",";
                i++;
                continue;
            } else if (table[i][j] == ",") {
                flag = false;
                std::cout << "LOOP" << std::endl;
                i = j = 0;
            } else {
                flag = false;
                std::cout << i << " " << j << std::endl;
                i = j = 0;
            }
        }
    }
    
    return 0;
}

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

int main()
{
	while(1)
	{
		int H, W;
		cin >> H>> W;

		if(H == 0 && W == 0)
		{
			break;
		}
		char map[200][200];
		/*for(int i = 0; i < 200; i++)
		{
			for(int j = 0; j < 200; j++)
			{
				map[i][j] = -1;
			}
		} */
		for(int iy = 0; iy < H; iy++)
		{
			for(int jx = 0; jx < W; jx++)
			{
				cin >> map[iy][jx];
			}
		}

		int px = 0;
		int py = 0;
		int count = 0;
		while(count < 10001)
		{
			if(map[py][px] == '>')
			{
				px++;
			}
			else if(map[py][px] == '<')
			{
				px--;
			}
			else if(map[py][px] == '^')
			{
				py--;
			}
			else if(map[py][px] == 'v')
			{
				py++;
			}
			else
			{
				cout << px << " " << py << endl;
				break;
			}
			count++;
		}
		if(count >= 10001)
		{
			cout << "LOOP" << endl;
		}

	}
	

}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>

int main() {
  int w, h;
  while(cin >>w >>h && w){
    vector<string> v(h);
    REP(i, h) cin >>v[i];
    vector< vector<bool> > visited(h, vector<bool>(w, false));
    int ny = 0, nx = 0;
    while(v[ny][nx] != '.' && !visited[ny][nx]){
      visited[ny][nx] = true;
      if(v[ny][nx] == '>') ++nx;
      if(v[ny][nx] == '<') --nx;
      if(v[ny][nx] == 'v') ++ny;
      if(v[ny][nx] == '^') --ny;
    }
    if(!visited[ny][nx]) cout <<nx <<" " <<ny <<endl;
    else cout <<"LOOP" <<endl;
  }
  return 0;
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int w,h;
   bool flag=false;
   char map[100+5][100+5];
   while(cin>>w>>h&&(w||h))
   {
     for(int i=0;i<h;i++)
     {
       for(int j=0;j<w;j++)
       {
         cin>>map[i][j];        
       }        
     }               
     int step=0;
     int x=0;
     int y=0;
     while(1)
     {
       while(map[x][y]=='>') 
       {
         x++;
         step++;
         //cout<<">"<<" ";                      
       }        
       while(map[x][y]=='<')
       {
         x--;
         step++;   
         //cout<<"<"<<" ";                   
       }
       while(map[x][y]=='v')
       {
         y++;
         step++;         
         //cout<<"v"<<" ";             
       }
       while(map[x][y]=='^')
       {
         y--;
         step++;         
         //cout<<"^"<<" ";             
       }
       if(step>(w*h))
       {
         flag=true;
         break;            
       }
       if(map[x][y]=='.')
       {
         break;                  
       }
       if(flag) break;
     }        
     if(flag) cout<<"LOOP"<<endl;
     else cout<<x<<" "<<y<<endl;
   }
   //while(1);
   return 0;
 }

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

using namespace std;

char data[101][101];

pair<int, int> search(pair<int, int> p);

int main()
{
    int n, m;

    while (cin >> n >> m, n || m) {
        for (int i = 0; i < n; i++) {
            cin >> data[i];
        }
        bool c[101][101] = {false};
        pair<int, int> pos = make_pair(0, 0);
        while (1) {
            pair<int, int> np = search(pos);
            if (np == pos) {
                cout << pos.second << " " << pos.first << endl;
                break;
            } else {
                pos = np;
            }
            if (c[pos.first][pos.second]) {
                puts("LOOP");
                break;
            } else {
                c[pos.first][pos.second] = true;
            }
        }
    }
    return 0;
}

pair<int, int> search(pair<int, int> p)
{
    if (data[p.first][p.second] == 'v') {
        return make_pair(p.first+1, p.second);
    } else if (data[p.first][p.second] == '^') {
        return make_pair(p.first-1, p.second);
    } else if (data[p.first][p.second] == '>') {
        return make_pair(p.first, p.second+1);
    } else if (data[p.first][p.second] == '<') {
        return make_pair(p.first, p.second-1);
    } else {
        return p;
    }
}