/** ____ ____ ____ ____ ____ ____ ||l |||e |||i |||n |||a |||d || ||__|||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\|/__\| **/ #include #define endl '\n' using namespace std; typedef long long ll; const int maxn = 1024, maxm = 1024, maxf = 1024; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } struct tourists { int a, b, c; } tour[maxf]; bool cmp(tourists t1, tourists t2) { return t1.a < t2.a; } int manhatten(pair < int, int > p1, pair < int, int > p2) { return abs(p1.first - p2.first) + abs(p1.second - p2.second); } bool random_cmp(pair < int, int > p1, pair < int, int > p2) { return rand() < rand(); } pair < int, int > bus[maxm]; pair < pair < int, int >, int > stop[maxn]; int n, m, t, f, used[maxm], d[maxm][maxm], event[maxn], limit, rl[maxn]; void read() { cin >> n; for (int i = 1; i <= n; i ++) cin >> stop[i].first.first >> stop[i].first.second, stop[i].second = i; cin >> m; for (int i = 1; i <= m; i ++) cin >> bus[i].first >> bus[i].second; cin >> t >> f; for (int i = 1; i <= f; i ++) cin >> tour[i].a >> tour[i].b >> tour[i].c; cin >> limit; } void solve() { ///sort(stop + 1, stop + n + 1); sort(tour + 1, tour + f + 1, cmp); for (int i = 1; i <= n; i ++) { ///cout << stop[i].first.first << " " << stop[i].first.second << " " << stop[i].second << endl; rl[i] = stop[i].second; } for (int i = 1; i <= f; i ++) event[rl[tour[i].b]] = max(event[rl[tour[i].b]], tour[i].a); for (int i = 1; i <= n; i ++) for (int j = i + 1; j <= n; j ++) d[i][j] = d[j][i] = manhatten(stop[i].first, stop[j].first); for (int i = 1; i <= n; i ++) used[i] = 1; for (int i = 1; i <= f; i ++) used[rl[tour[i].b]] = 0; if (limit != -1) { for (int i = 1; i <= m; i ++) { int st = 1, sum = 0; while(st <= n && used[st] == 1) st ++; if (st > n) { cout << 0 << endl << 0 << endl; continue; } used[st] = 1; vector < int > v; v.push_back(st); while(true) { int minn = 1e9, next = 1; for (int i = 1; i <= n; i ++) if (used[i] == 0 && d[st][i] < minn) minn = d[st][i], next = i; //cout << rl[next] << " " << rl[st] << " " << d[st][next] << " " << stop[next].first.first << " " << stop[next].first.second << endl; if (minn == 1e9 || sum + minn + d[next][v[0]] > bus[i].first) break; v.push_back(next); used[next] = 1; st = next; sum += minn; } int ti = 1e9, t2 = 0; cout << v.size() + 1 << " "; for (int i = 0; i < v.size(); i ++) cout << rl[v[i]] << " ", ti = min(ti, event[v[i]]), t2 = max(t2, event[v[i]]); cout << rl[v[0]]; cout << endl; cout << 2 << " " << ti << " " << max(ti + sum + bus[i].second + d[v[v.size() - 1]][v[0]], t2 + 1) << endl; } } else { for (int i = 1; i <= m; i ++) { int st = 1, sum = 0; while(st <= n && used[st] == 1) st ++; if (st > n) { cout << 0 << endl << 0 << endl; continue; } used[st] = 1; vector < int > v; v.push_back(st); while(true) { int minn = 1e9, next = 1; for (int i = 1; i <= n; i ++) if (used[i] == 0 && d[st][i] < minn) minn = d[st][i], next = i; if (minn == 1e9 || sum + minn + d[next][v[0]] > bus[i].first) break; v.push_back(next); used[next] = 1; st = next; sum += minn; } int ti = 1e9, t2 = 0; cout << v.size() + 1 << " "; for (int i = 0; i < v.size(); i ++) cout << rl[v[i]] << " ", ti = min(ti, event[v[i]]), t2 = max(t2, event[v[i]]); cout << rl[v[0]]; cout << endl; ///cout << 2 << " " << ti << " " << max(ti + sum + bus[i].second + d[v[v.size() - 1]][v[0]] + sum, t2 + 1) << endl; sum += bus[i].second + d[v[v.size() - 1]][v[0]]; int last = 1; vector < int > times; while(last <= t2) { times.push_back(last); last = last + sum; } times.push_back(last); cout << times.size() << " "; for (int i = 0; i < times.size(); i ++) cout << times[i] << " "; cout << endl; } } } int main() { srand(time(NULL)); freopen ("wonderland.in", "r", stdin); freopen ("wonderland.out", "w", stdout); read(); solve(); return 0; } /* 20 35 0 47 17 43 9 6 15 47 1 14 5 16 0 14 10 17 7 4 13 26 20 27 18 17 18 34 7 16 19 14 20 39 9 22 3 3 10 27 10 1 256 1132 10000 15 1035 7 21 1757 12 28 226 6 5 509 6 33 2727 12 12 3039 19 28 1208 9 9 2051 8 8 1243 18 14 781 5 3 77 7 20 4191 20 29 3605 10 32 3292 18 13 1221 2 32 420 6 1 1 6 2 4 4 6 5 5 6 2 3 3 20 10 7 1 2 2 240 7 1 1 5 2 2 10 3 5 20 100 4 1 120 6 2 125 3 3 128 4 4 42 */