Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"math"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	dd := make([][]int, 1000)
	for i := range dd {
		dd[i] = make([]int, 1000)
	}
	num := make([]int,1000)
	inv := make([]int, 1001)
	x := make([]int, 1000)
	y := make([]int, 1000)
	vv := make([]int, 1000)
	nowt := make([]float64, 1000)
	rev := make([]int, 1000)
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf1 := strings.Split(scanner.Text(), " ")
			num[i], _ = strconv.Atoi(buf1[0])
			x[i], _ = strconv.Atoi(buf1[1])
			y[i], _ = strconv.Atoi(buf1[2])
			inv[num[i]] = i
		}
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				dd[i][j]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])
			}
		}
		scanner.Scan()
		m, _ := strconv.Atoi(scanner.Text())
		for i := 0; i < m; i++ {
			scanner.Scan()
			buf2 := strings.Split(scanner.Text(), " ")
			c, _ := strconv.Atoi(buf2[0])
			d, _ := strconv.Atoi(buf2[1])
			c = inv[c]
			d = inv[d]
			for j := 0; j < n; j++ {
				vv[j] = 0
				nowt[j]=999999999
				rev[j]=-1
			}
			nowt[c]=0
			for j := 0; j < n; j++ {
				M := 99999999
				at := 0
				for k := 0; k < n; k++ {
					if vv[k] == 0 && float64(M) > nowt[k] {
						M=int(nowt[k])
						at = k
					}
				}
				if M > 90000000 {
					break
				}
				vv[at]=1
				for k := 0; k < n; k++ {
					if vv[k] == 0 && dd[at][k]<=2500&&nowt[k]>nowt[at]+math.Sqrt(float64(dd[at][k])) {
						nowt[k]=nowt[at]+math.Sqrt(float64(dd[at][k]))
						rev[k] = at
					}
				}
			}
			if vv[d] == 0 {
				fmt.Println("NA")
			} else {
				stack := make([]int, 0)
				V := d
				for V != c {
					stack = append(stack, V)
					V = rev[V]
				}
				fmt.Print(num[c])
				for len(stack) > 0 {
					fmt.Printf(" %d", num[stack[len(stack)-1]])
					stack = stack[:len(stack)-1]
				}
				fmt.Println()
			}
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
using P = pair<ld, int>;
struct Edge{
    ld distance;
    int to;
    Edge(ld distance, int to) : distance(distance), to(to) {};
};
int main(){
    while(true){
        int n;
        cin >> n;
        if(!n) break;
        vector<pair<ld, ld>> coordinate(n);
        for(int i = 0; i < n; i++){
            int d, x, y;
            cin >> d >> x >> y;
            coordinate[d - 1] = make_pair(x, y);
        }
        vector<vector<Edge>> graph(n);
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                ld d = sqrt((coordinate[i].first - coordinate[j].first) * (coordinate[i].first - coordinate[j].first) + (coordinate[i].second - coordinate[j].second) * (coordinate[i].second - coordinate[j].second));
                if(d - 50 < 1e-10){
                    graph[i].emplace_back(d, j);
                    graph[j].emplace_back(d, i);
                }
            }
        }
        int m;
        cin >> m;
        vector<int> s(m), g(m);
        for(int i = 0; i < m; i++) {int a, b; cin >> a >> b; a--; b--; s[i] = a; g[i] = b;}
        for(int i = 0; i < m; i++){
            vector<P> dis(n, make_pair(1e10, -1));//距離,parent
            priority_queue<P, vector<P>, greater<P>> pq;//距離,current node
            dis[s[i]] = make_pair(0, -1);
            pq.emplace(0, s[i]);
            while(!pq.empty()){
                auto p = pq.top();
                pq.pop();
                if(p.first <= dis[p.second].first){
                    for(auto itr : graph[p.second]){
                        if(p.first + itr.distance < dis[itr.to].first){
                            dis[itr.to] = make_pair(p.first + itr.distance, p.second);
                            pq.emplace(dis[itr.to].first, itr.to);
                        }
                    }
                }
            }
            vector<int> out;
            out.push_back(g[i]);
            int pnt = g[i];
            while(true){
                auto itr = dis[pnt];
                if(itr.first > 9e9) {cout << "NA" << "\n"; break;}
                if(itr.second == -1) break;
                out.push_back(itr.second);
                pnt = itr.second;
            }
            if(out.size() != 1){
                for(int i = out.size() - 1; i >= 0; i--){
                    cout << out[i] + 1;
                    if(i != 0) cout << " "; 
                }
                cout << "\n";
            }
        }
    }
}

C++: #include <iostream>
#include <cmath>
#include <queue>
#include <algorithm>
#include <memory.h>
#include <vector>
#include <map>
#include <cstdlib>
#include <ctime>
using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef pair<double, int> state;
const int CLK = CLOCKS_PER_SEC;

int s, g;
double memo[100];
int pre[100];
int name[100];
double x[100];
double y[100];

map<int, int> nums;

double dis(int i, int j){
  return sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
}

double heuristics(int v){
  return dis(v, nums[g]);
}

int main(){
  int n, m;
  int b;
  int cnt = 0;
  while(cin >> n &&n){
    nums.clear();
    rep(i, n){
      cin >> b >> x[i] >> y[i];
      name[i] = b;
      nums[b] = i;
    }
    cin >> m;
    rep(i, m){
      memset(pre, -1, sizeof(pre));
      fill(memo, memo + 100, 1e10);
      cin >> s >> g;
      memo[nums[s]] = heuristics(nums[s]);
      priority_queue<state, vector<state>, greater<state> > que;
      que.push(state(heuristics(nums[s]), nums[s]));
      
      while(!que.empty()){
	cnt++;
	state st = que.top();
	que.pop();
	int v = st.second;
	double fcost = st.first;
	double gcost = fcost - heuristics(v);
	if(name[v] == g){
	  break;
	}
	if(fcost > memo[v]) continue;
	rep(j, n){
	  double d = dis(v, j);
	  if(d > 50.0) continue;
	  if(memo[j] > gcost + d + heuristics(j)){
	    memo[j] = gcost + d + heuristics(j);
	    pre[j] = v;
	    que.push(state(memo[j], j));
	  }
	}
      }
      if(pre[nums[g]] == -1 && s != g){
	cout << "NA" << endl;
      }else{
	vector<int> res;
	int v = nums[g];
	res.push_back(v);

	/*
	while(pre[v] >= 0){
	  v = pre[v];
	  res.push_back(v);
	}
	*/
	rep(j, (int)res.size()){
	  if(j != 0) cout << " " ;
	  cout << name[res[res.size() - 1 - j]];
	}
	cout << endl;
      }
    }
  }
  // cout << cnt << endl;
  return 0;
}