#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int maxn = 5005;
const double ex = 1e-7;
int w,n;
struct Node {
double d, l, r;
bool operator<(const Node& input) {
return d < input.d;
}
}node[maxn];
int check(double x) {
double l = atan2(node[0].d, node[0].r - x), r = atan2(node[0].d, node[0].l - x);
for (int i = 1; i < n; i++) {
double ll = atan2(node[i].d, node[i].r - x);
double rr = atan2(node[i].d, node[i].l - x);
//当前角度太大了 需要右移变小
if (ll - r > ex) return 1;
//当前角度太小了 需要左移变大
if (rr - l < -ex) return -1;
l = max(ll, l);
r = min(rr, r);
}
//可穿
return 0;
}
bool IsOk() {
double l = 0, r = w;
while (r - l > ex) {
double mid = (r + l) / 2;
int ret = check(mid);
if (ret == 0)return true;
else if (ret == 1) l = mid;
else r = mid;
}
return false;
}
int main()
{
int t;
cin >> t;
while (t--) {
cin >> w >> n;
for (int i = 0; i < n; i++) {
cin >> node[i].d >> node[i].l >> node[i].r;
}
sort(node, node + n);
if (IsOk())cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}
07-23
288
11-05
619