#include #include #include #include #include #include using namespace std; int solve(int n, pair &hfs); int main() { int n, m, k; cin >> n >> m >> k; vector > > h; h.resize(m); multiset c1; int a,b; long c; for (int i = 0; i> a >> b >> c; c1.insert(c); h[i] = make_pair(c,make_pair(a,b)); } long x; set nr; for (int i = 0; i < k; i++) { set r; cin >> x; auto itc1 = c1.find(x); int f = distance(c1.begin(),itc1); int s = nr.size(); while (1) { if(*(itc1)==x){ if (i == 0) { r.insert(h[f].second.first); r.insert(h[f].second.second); } else { int y; auto itnr = nr.begin(); for (int j = 0; j &hfs) { if (n == hfs.first) { return hfs.second; } else if (n == hfs.second) { return hfs.first; } return 0; }