#include using namespace std; // ==================================================================================================================== // Functions // ==================================================================================================================== namespace { unsigned int seed = 869120; unsigned int Rand() { seed ^= seed << 13; seed ^= seed >> 17; seed ^= seed << 5; return (seed & 2147483647); } double Randouble() { return Rand() / 2147483648.0; } double GetTime() { return 1.0 * clock() / CLOCKS_PER_SEC; } }; struct Info { int a, s, b, t; }; int get_duration(int px, int py, int qx, int qy) { double dst = sqrt(1.0 * ((px - qx) * (px - qx) + (py - qy) * (py - qy))); double tm = (60.0 * dst / 800.0) + 40.0; return (int)((tm + 4.999999999) / 5.0) * 5; } int convert(string s) { int tm = 60 * stoi(s.substr(0, 2)) + stoi(s.substr(3, 2)); return tm; } string convert2(int tm) { string hh = to_string(tm / 60); while (hh.size() < 2) hh = "0" + hh; string mm = to_string(tm % 60); while (mm.size() < 2) mm = "0" + mm; return hh + ":" + mm; } // ==================================================================================================================== // Main Part // ==================================================================================================================== int main() { // step 1. input int N, R; cin >> N >> R; vector x(N), y(N), w(N); for (int i = 0; i < N; i++) { cin >> x[i] >> y[i] >> w[i]; } int M; cin >> M; vector v(M); for (int i = 0; i < M; i++) { string s1, s2; cin >> v[i].a >> s1 >> v[i].b >> s2; v[i].s = convert(s1); v[i].t = convert(s2); } int K; cin >> K; // step 2. prepare vector sum(N + 1, 0); for (int i = 0; i < N; i++) { sum[i + 1] = sum[i] + w[i]; } // step 3. solve auto get_position = [&]() -> int { int x = Rand() % sum[N] + 1; return lower_bound(sum.begin(), sum.end(), x) - sum.begin() - 1; }; for (int i = 0; i < K; i++) { int current_time = 360 + 5 * (rand() % 10); int pos = get_position(); vector plan; while (true) { int nex_pos; while (true) { nex_pos = get_position(); if (pos != nex_pos) break; } int goal_time = current_time + get_duration(x[pos], y[pos], x[nex_pos], y[nex_pos]); if (goal_time > 1260) break; plan.push_back(Info{pos, current_time, nex_pos, goal_time}); goal_time += 5 * (rand() % 3); current_time = goal_time; pos = nex_pos; } // output cout << plan.size() << endl; for (int i = 0; i < plan.size(); i++) { cout << plan[i].a + 1 << " " << convert2(plan[i].s) << " " << plan[i].b + 1 << " " << convert2(plan[i].t) << endl; } } return 0; }