#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); vector c; c.resize(m); int a,b; for (int i = 0; i> a >> b >> c[i]; h[i] = make_pair(c[i],make_pair(a,b)); } sort(h.begin(),h.end()); sort(c.begin(),c.end()); long x; set nr; for (int i = 0; i < k; i++) { set r; cin >> x; int f = distance(c.begin(),lower_bound(c.begin(),c.end(),x)); while (f &hfs) { if (n == hfs.first) { return hfs.second; } else if (n == hfs.second) { return hfs.first; } return 0; }