#include #include #include #include #include #define no cout << "KHONG" << endl #define yes cout << step << endl using namespace std; int step = 0; int n, m; struct POINT { double x, y, z; }; vector points; int compare(POINT a, POINT b) { if (a.x < b.x) return -1; else if (a.x > b.x) return 1; else if (a.y < b.y) return -1; else if (a.y > b.y) return 1; else if (a.z < b.z) return -1; else if (a.z > b.z) return 1; else return 0; } void get_info() { cin >> n; POINT temp; for (int i = 0; i < n; i++) { cin >> temp.x >> temp.y >> temp.z; points.push_back(temp); } } int BinSearch(vector A, POINT a) { int l = 0, r = n - 1, i; while (l <= r) { step++; i = (r - l) / 2 + l; if (compare(A[i], a) == 0) return i; if (compare(A[i], a) == -1) l = i + 1; if (compare(A[i], a) == 1) r = i - 1; //cout << "$$ " << l << " - " << r << " | " << i << endl; } return -1; } void solve() { step = 0; POINT temp; cin >> temp.x >> temp.y >> temp.z; if (BinSearch(points, temp) == -1) no; else yes; } int main() { get_info(); cin >> m; for (int i = 0; i < m; i++) solve(); return 0; }