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;

int main() {
    int H, W;
    
    while (cin >> H >> W && H + W != 0) {
        char room[101][101];
        bool visited[101][101] = {0};

        for (int h = 0; h < H; ++h) {
            for (int w = 0; w < W; ++w) {
                cin >> room[h][w];
            }
        }

        int x = 0, y = 0;
        bool loop = false;

        while(room[x][y] != '.') {
            if (visited[x][y]) {
                loop = true;
                break;
            }
            else {
                visited[x][y] = true;
            }

            if (room[x][y] == '>') y++;
            else if (room[x][y] == '<') y--;
            else if (room[x][y] == '^') x--;
            else if (room[x][y] == 'v') x++;
        }

        if (loop) {
            cout << "LOOP" << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }

    return 0;
}

C++: //51
#include<iostream>

using namespace std;

int main(){
  for(int W,H;cin>>W>>H,W|H;){
    char g[200][200];
    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
	cin>>g[y][x];
      }
    }
    int y=0,x=0;
    while(g[y][x]!='.'&&g[y][x]!='\0'){
      int ny=y+(g[y][x]=='v')-(g[y][x]=='^');
      int nx=x+(g[y][x]=='>')-(g[y][x]=='<');
      g[y][x]='\0';
      y=ny;
      x=nx;
    }
    if(g[y][x]){
      cout<<x<<' '<<y<<endl;
    }else{
      cout<<"LOOP"<<endl;
    }
  }
  return 0;
}

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

using namespace std;

int judge[128][128];

int main()
{
	char f[128][128];

	int w, h, i, j, ex, ey;

	while(cin >> h >> w, w || h)
	{
		i = 0; j = 0;

		for(int k = 0; k < h; k++)
		{
			cin >> f[k];
			for(int l = 0; l < w; l++)
			{
				judge[k][l] = 0;
			}
		}
		while(1)
		{
			if(judge[i][j] == 1)
			{
				ex = -1; ey = -1;
				break;
			}
			else if(f[i][j] == '.')
			{
				ex = j; ey = i;
				break;
			}

			judge[i][j] = 1;

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

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

C++: #include<iostream>
using namespace std;
int w,h,v[200][200];
char s[200][200];
void func(int y,int x){
	v[y][x]=0;
	if(s[y][x]=='.')
		cout<<x<<' '<<y<<endl;
	else if(s[y][x]=='>'){
		if(v[y][x+1]==1)
			func(y,x+1);
		else
		cout<<"LOOP"<<endl;
	}
	else if(s[y][x]=='<'){
		if(v[y][x-1]==1)
			func(y,x-1);
		else
		cout<<"LOOP"<<endl;
	}
	else if(s[y][x]=='v'){
		if(v[y+1][x]==1)
			func(y+1,x);
		else
		cout<<"LOOP"<<endl;
	}
	else if(s[y][x]=='^'){
		if(v[y-1][x]==1)
			func(y-1,x);
		else
		cout<<"LOOP"<<endl;
	}
	
}

int main(){
	while(cin>>h>>w,w||h){
		for(int i=0;i<h;i++)
		cin>>s[i];
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		v[i][j]=1;
		func(0,0);
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


typedef int ll;


using namespace std;

int main()
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0) break;

		vector<int> order;
		map<int, ll> sale;
		for (int i = 0; i < n; ++i)
		{
			int no, value, num;
			scanf("%d %d %d", &no, &value, &num);
			if (!sale[no])
			{
				sale.insert(make_pair(no, 0));
				order.push_back(no);
			}
			ll t = (ll)value * num;
			sale[no] += t;
		}
		bool any = false;
		for (int i = 0; i < order.size(); ++i)
		{
			if (sale[order[i]] >= 1000000)
			{
				printf("%d\n", order[i]);
				any = true;
			}
		}
		if (!any)
			printf("NA\n");
	}

	return 0;
}

C++: import java.util.*;

class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(true){
			int h = in.nextInt(), w = in.nextInt();
			if(w==0 && h==0) return ;
			String board[] =  new String[h];
			for(int i=0; i<h; i++){
				board[i] = in.next();
			}
			int cx = 0, cy = 0;
			boolean isLoop = false;
			HashSet<Integer> s = new HashSet<Integer>();
			while(board[cy].charAt(cx) != '.'){
				char c = board[cy].charAt(cx);
				cx += (c == '>')?1:(c == '<')?-1:0;
				cy += (c == '^')?-1:(c == 'v')?1:0;
				if(s.contains(new Integer(cx*10000+cy))){
					isLoop = true;
					break;
				}
				else{
					s.add(new Integer(cx*10000+cy));
				}
			}
			if(isLoop){
				System.out.println("LOOP");
			}
			else{
				System.out.println(cx + " " + cy);
			}
		}
	}
	
}

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

int main(){
    int w,h;
    int ichi[101][101]={0};
    while(1){
        int i=0,j=0;
        cin >> w >> h;
        if(w == 0 && h == 0){
            break;
        }
        char map[w][h];
        for(int n=0;n<w;n++){
            for(int k=0;k<h;k++){
                cin >> map[n][k];
            }
        }
        while(1){
            if(ichi[i][j] == 1){
                cout << "LOOP" << endl;
                break;
            }
            else if(map[i][j] == '.'){
                cout << j << " " << i << endl;
                break;
            }
            if(map[i][j] == '>'){
                ichi[i][j] = 1;
                j++;
            }
            else if(map[i][j] == '<'){
                ichi[i][j] = 1;
                j--;
            }
            else if(map[i][j] == '^'){
                ichi[i][j] = 1;
                i--;
            }
            else if(map[i][j] == 'v'){
                ichi[i][j] = 1;
                i++;
            }
        }
    }
}

C++: #include<iostream>
//#include<algorithm>
#include<string>
#include<vector>
//#include <cstring>
//#include <cstdio>
int main() {
	int a, b;
	while (std::cin >> a >> b, a + b != 0) {
		std::vector<std::vector<char>> ch(a, std::vector<char>(b));
		std::vector<std::vector<char>> ch2(a, std::vector<char>(b,0));
		int x=0, y=0;
		for (int i = 0; i < a; ++i) {
			for (int j = 0; j < b; ++j) {
				std::cin >> ch[i][j];
			}
		}
		while (ch[x][y] != '.') {
			if (ch2[x][y] ==1) { std::cout << "LOOP" << std::endl; break; }
			ch2[x][y]++;
			if (ch[x][y] == '>')y++;
			else if (ch[x][y] == '<')y--;
			else if (ch[x][y] == '^')x--;
			else if (ch[x][y] == 'v')x++;
		}
		if (ch2[x][y] == 0)std::cout << y <<" "<<x<< std::endl;
	}
	return 0;
}