#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; //#define int long long typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; constexpr ll mod = 998244353; const ll INF = mod * mod; typedef pairP; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) #define all(v) (v).begin(),(v).end() typedef pair LP; typedef long double ld; typedef pair LDP; const ld eps = 1e-12; const ld pi = acos(-1.0); ll mod_pow(ll x, ll n, ll m) { ll res = 1; while (n) { if (n & 1)res = res * x % m; x = x * x % m; n >>= 1; } return res; } struct modint { ll n; modint() :n(0) { ; } modint(ll m) :n(m) { if (n >= mod)n %= mod; else if (n < 0)n = (n % mod + mod) % mod; } operator int() { return n; } }; bool operator==(modint a, modint b) { return a.n == b.n; } modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; } modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; } modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; } modint operator+(modint a, modint b) { return a += b; } modint operator-(modint a, modint b) { return a -= b; } modint operator*(modint a, modint b) { return a *= b; } modint operator^(modint a, int n) { if (n == 0)return modint(1); modint res = (a * a) ^ (n / 2); if (n % 2)res = res * a; return res; } ll inv(ll a, ll p) { return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p); } modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); } const int max_n = 1 << 18; modint fact[max_n], factinv[max_n]; void init_f() { fact[0] = modint(1); for (int i = 0; i < max_n - 1; i++) { fact[i + 1] = fact[i] * modint(i + 1); } factinv[max_n - 1] = modint(1) / fact[max_n - 1]; for (int i = max_n - 2; i >= 0; i--) { factinv[i] = factinv[i + 1] * modint(i + 1); } } modint comb(int a, int b) { if (a < 0 || b < 0 || a < b)return 0; return fact[a] * factinv[b] * factinv[a - b]; } struct edge { int to; ld cost; }; using speP = pair; ld memo[2000][2000]; void solve() { int n, m,k; cin >> n >> m>>k; vector> G(n); vector x(n), y(n); int s, t; cin >> s >> t; s--; t--; rep(i, n)cin >> x[i] >> y[i]; rep(i, n)Rep(j, i + 1, n) { ld dist = sqrtl(pow(x[j] - x[i], 2) + pow(y[j] - y[i],2)); memo[i][j] = memo[j][i] = dist; } rep(i, m) { int p, q; cin >> p >> q; p--; q--; ld dist = sqrtl(pow(x[p] - x[q], 2) + pow(y[p] - y[q], 2)); G[p].push_back({ q,dist }); G[q].push_back({ p,dist }); } vector dist(n, INF); vector par(n); dist[s] = 0; priority_queue, greater> q; /*q.push({ 0,s }); while (!q.empty()) { speP p = q.top(); q.pop(); int id = p.second; if (dist[id] < p.first)continue; for (edge e : G[id]) { ld nd = e.cost + dist[id]; if (nd < dist[e.to]) { par[e.to] = id; dist[e.to] = nd; q.push({ nd,e.to }); } } }*/ map, bool> chked; auto calc = [&](vector v)->pair> { if (chked[v])return { -1,{} }; chked[v] = true; vectorban(n, false); for (int id : v)ban[id] = true; fill(all(dist), INF); dist[v.back()] = 0; q.push({ 0,v.back() }); while (!q.empty()) { speP p = q.top(); q.pop(); int id = p.second; if (dist[id] < p.first)continue; for (edge e : G[id]) { if (ban[e.to])continue; ld nd = e.cost + p.first; if (nd < dist[e.to]) { dist[e.to] = nd; par[e.to] = id; q.push({ nd,e.to }); } } } if (dist[t] == INF)return { -1,{} }; vector res2 = v; vector las; int cur = t; while (cur != v.back()) { las.push_back(cur); cur = par[cur]; } per(i, (int)las.size())res2.push_back(las[i]); return { dist[t],res2 }; }; pair> cur = calc({ s }); vector ans(k, -1); ans[0] = cur.first; vector> pre; pre.push_back(cur.second); set>> st; rep1(aa, k-1) { vector las = pre.back(); //cout << "??? " << las.size() << "\n"; vector ids(pre.size()); rep(i, pre.size())ids[i] = i; vector vc; ld s = 0; vector ban(n, false); rep(i, (int)las.size() - 1) { ban[las[i]] = true; vector nex; for (int id : ids) { if (pre[id][i] == las[i])nex.push_back(id); } swap(nex, ids); //cout << "! " << ids.size() << "\n"; vc.push_back(las[i]); for (edge e : G[las[i]]) { bool valid = true; if (ban[e.to])valid = false; for (int id : ids)if (e.to == pre[id][i + 1])valid = false; if (valid) { //cout << "? " << i << " " << e.to << "\n"; vc.push_back(e.to); pair> p = calc(vc); if (p.first >= 0) { p.first += s+memo[las[i]][e.to]; st.insert(p); } vc.pop_back(); } } s += memo[las[i]][las[i + 1]]; } if (st.empty())break; pair> ne = *st.begin(); st.erase(st.begin()); ans[aa] = ne.first; pre.push_back(ne.second); } rep(i, k) { if (ans[i] < 0)cout << -1 << "\n"; else cout << ans[i] << "\n"; } } signed main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(10); //init_f(); //cout << grandy(2, 3, false, false) << "\n"; //int t; cin >> t; rep(i, t) solve(); return 0; }