#include #include #include #include #include using namespace std; int solve(int n, int f, vector > > &h); int main() { int n, m, k; cin >> n >> m >> k; vector > > h; h.resize(m); vector c1; c1.resize(m); for (int i = 0; i> a >> b >> c1[i]; h[i] = make_pair(c1[i],make_pair(a,b)); } sort(h.begin(), h.end()); sort(c1.begin(), c1.end()); long x; vector nr; for (int i = 0; i < k; i++) { vector r; cin >> x; size_t f; f = distance(c1.begin(), lower_bound(c1.begin(), c1.end(), x)); while (f > > &h) { if (n == h[f].second.first) { return h[f].second.second; } else if (n == h[f].second.second) { return h[f].second.first; } return 0; }