#include using namespace std; struct dual_segment_tree{ int N; vector ST; dual_segment_tree(int n){ N = 1; while (N < n){ N *= 2; } ST.resize(N * 2 - 1, 0); } void range_add(int L, int R, long long x, int i, int l, int r){ if (r <= L || R <= l){ } else if (L <= l && r <= R){ ST[i] += x; } else { int m = (l + r) / 2; range_add(L, R, x, i * 2 + 1, l, m); range_add(L, R, x, i * 2 + 2, m, r); } } void range_add(int L, int R, long long x){ range_add(L, R, x, 0, 0, N); } long long operator [](int k){ k += N - 1; long long ans = ST[k]; while (k > 0){ k = (k - 1) / 2; ans += ST[k]; } return ans; } }; int main(){ int Q; cin >> Q; vector K(Q), L(Q), M(Q), N(Q), X(Q); for (int i = 0; i < Q; i++){ cin >> K[i] >> L[i] >> M[i] >> N[i] >> X[i]; } vector X2 = X; sort(X2.begin(), X2.end()); X2.erase(unique(X2.begin(), X2.end()), X2.end()); int cnt = X2.size(); dual_segment_tree ST_A(cnt), ST_B(cnt), ST_L(cnt), ST_R(cnt); for (int i = 0; i < Q; i++){ if (K[i] > 0){ int pl = partition_point(X2.begin(), X2.end(), [&](long long x){ return K[i] * x + L[i] < 0; }) - X2.begin(); int pr = partition_point(X2.begin(), X2.end(), [&](long long x){ return K[i] * x + L[i] <= 0; }) - X2.begin(); ST_A.range_add(pr, cnt, K[i]); ST_B.range_add(pr, cnt, L[i]); ST_L.range_add(pr, cnt, K[i]); ST_R.range_add(pl, cnt, K[i]); } else if (K[i] < 0){ int pl = partition_point(X2.begin(), X2.end(), [&](long long x){ return K[i] * x + L[i] > 0; }) - X2.begin(); int pr = partition_point(X2.begin(), X2.end(), [&](long long x){ return K[i] * x + L[i] >= 0; }) - X2.begin(); ST_A.range_add(0, pr, K[i]); ST_B.range_add(0, pr, L[i]); ST_L.range_add(0, pr, K[i]); ST_R.range_add(0, pl, K[i]); } else { ST_B.range_add(0, cnt, max(L[i], 0)); } if (M[i] > 0){ int pl = partition_point(X2.begin(), X2.end(), [&](long long x){ return M[i] * x + N[i] < 0; }) - X2.begin(); int pr = partition_point(X2.begin(), X2.end(), [&](long long x){ return M[i] * x + N[i] <= 0; }) - X2.begin(); ST_A.range_add(pr, cnt, -M[i]); ST_B.range_add(pr, cnt, -N[i]); ST_L.range_add(pr, cnt, -M[i]); ST_R.range_add(pl, cnt, -M[i]); } else if (M[i] < 0){ int pl = partition_point(X2.begin(), X2.end(), [&](long long x){ return M[i] * x + N[i] > 0; }) - X2.begin(); int pr = partition_point(X2.begin(), X2.end(), [&](long long x){ return M[i] * x + N[i] >= 0; }) - X2.begin(); ST_A.range_add(0, pr, -M[i]); ST_B.range_add(0, pr, -N[i]); ST_L.range_add(0, pr, -M[i]); ST_R.range_add(0, pl, -M[i]); } else { ST_B.range_add(0, cnt, -max(N[i], 0)); } int p = lower_bound(X2.begin(), X2.end(), X[i]) - X2.begin(); __int128_t y = (__int128_t) ST_A[p] * X[i] + ST_B[p]; long long l = ST_L[p]; long long r = ST_R[p]; if (y == 0 && l == 0 && r == 0){ cout << "Yes" << endl; } else { cout << "No" << endl; } } }