#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n, m, q; cin >> n >> m >> q; vector>> g(n); for (int i = 1; i <= m; i++) { int u, v, w; cin >> u >> v >> w; g[u - 1].push_back({v - 1, -w, i}); } vector p(n, 1e9); { // bellman-ford p[0] = 0; for (int i = 0; i < n - 1; i++) { for (int u = 0; u < n; u++) { for (auto [v, w, _] : g[u]) { p[v] = min(p[v], p[u] + w); } } } } vector>> g2(n); for (int u = 0; u < n; u++) { for (auto [v, w, i] : g[u]) { g2[u].push_back({v, w - p[v] + p[u], i}); } } const int INF = 1e9; vector ok(m + 1, true); for (; q--;) { int j; cin >> j; ok[j] = !ok[j]; vector dist(n, INF); dist[0] = 0; using pii = pair; priority_queue, greater> pq; pq.push({0, 0}); while (!pq.empty()) { auto [d, u] = pq.top(); pq.pop(); if (dist[u] < d) { continue; } for (auto [v, w, i] : g2[u]) { if (ok[i]) { if (dist[v] > d + w) { dist[v] = d + w; pq.push({dist[v], v}); } } } } if (dist[n - 1] == INF) { cout << "NaN\n"; } else { cout << -dist[n - 1] - p[n - 1] << "\n"; } } }