#include using namespace std; #define DEBUG(x) cerr<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair template pair operator+(const pair &s, const pair &t) { return pair(s.first + t.first, s.second + t.second); } template pair operator-(const pair &s, const pair &t) { return pair(s.first - t.first, s.second - t.second); } template ostream& operator<<(ostream& os, pair p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--) #define rrep1(i,n) for(int i=(int)(n);i>0;i--) #define REP(i,a,b) for(int i=a;i bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const long double pi = 3.1415926535897932384626433832795028841971L; #define Sp(p) cout<; vector> G; int k; using bit = bitset<2000>; using PP = pair>; class Cmp { public: bool operator() (PP a, PP b) { return a.first > b.first; } }; vector>> dijkstra(int s, int n){ priority_queue, Cmp > pq; // priority_queue, greater > pq; int i; int hash = 0; vector>> d(n); d[s].insert({0, hash}); bit temp = bit(); temp[s] = true; pq.push(PP(0, {pii(s, hash++), temp})); while(!pq.empty()){ PP f=pq.top(); pq.pop(); int u=f.second.first.first, nowhash = f.second.first.second; bit mask = f.second.second; double cost = f.first; if (not d[u].count({cost, nowhash})) continue; for (i = 0; i < G[u].size(); i++) { int v = G[u][i].second; double ncost = cost + G[u][i].first; if (mask[v]) continue; if (d[v].size() == k) { auto itr = d[v].end(); itr--; if (itr->first <= ncost) continue; d[v].erase(itr); } d[v].insert({ncost, hash}); bit nmask = mask; nmask[v] = true; pq.push({ncost, {pii(v, hash++), nmask}}); } } return d; } signed main() { int n, m; cin >> n >> m >> k; G.resize(n); int x, y; cin >> x >> y; x--; y--; vector xy(n); rep (i, n) { cin >> xy[i].first >> xy[i].second; } rep (i, m) { int u, v; cin >> u >> v; u--; v--; pii xy1 = xy[u], xy2 = xy[v]; double dist = sqrt((xy1.first - xy2.first) * (xy1.first - xy2.first) + (xy1.second - xy2.second) * (xy1.second - xy2.second)); G[u].push_back(P(dist, v)); G[v].push_back(P(dist, u)); } auto dist = dijkstra(x, n); for (auto itr = dist[y].begin(); itr != dist[y].end(); itr++) { Sp(itr->first); k--; } while (k--) { cout << -1 << endl; } }