#include "iostream"
#include "algorithm"
#include "vector"
#include "set"
#include "map"
#include "cstring"
#include "string"
#include "vector"
#include "cassert"
#include "queue"
#include "cstdio"
#include "cstdlib"
#include "ctime"
#include "cmath"
#include "bitset"
using namespace std;
typedef long long ll;
typedef pair < int, int > ii;
const int N = 1e5 + 5;
const int LOG = 17;
int n, q;
vector < ii > v[N];
ll to[N];
int lca[LOG][N], dep[N];
ii edge[LOG][N];
void dfs(int p, int x) {
dep[x] = dep[p] + 1;
lca[0][x] = p;
for(int i = 1; i < LOG; i++) {
lca[i][x] = lca[i - 1][lca[i - 1][x]];
edge[i][x] = max(edge[i - 1][x], edge[i - 1][lca[i - 1][x]]);
}
for(auto tmp : v[x]) {
int u = tmp.first, e = tmp.second;
if(u != p) {
to[u] = to[x] + e;
edge[0][u] = {e, u};
dfs(x, u);
}
}
}
int getLca(int x, int y) {
if(dep[x] < dep[y])
swap(x, y);
for(int i = LOG - 1; i >= 0; i--)
if(dep[x] - (1 << i) >= dep[y])
x = lca[i][x];
if(x == y)
return x;
for(int i = LOG - 1; i >= 0; i--) {
if(lca[i][x] != lca[i][y]) {
x = lca[i][x], y = lca[i][y];
}
}
return lca[0][x];
}
ii getLongest(int x, int y) {
if(dep[x] < dep[y])
swap(x, y);
ii res = {0, 0};
for(int i = LOG - 1; i >= 0; i--) {
if(dep[x] - (1 << i) >= dep[y]) {
res = max(res, edge[i][x]);
x = lca[i][x];
}
}
return res;
}
bool way(int x, int y) {
return dep[x] > dep[y];
}
ll getDist(int x, int y) {
if(dep[x] < dep[y])
swap(x, y);
return to[x] - to[y];
}
bool check(int x1, int y1, ll t1, int x2, int y2, ll t2) {
if(x1 == y1 or x2 == y2)
return 0;
int a1 = x1, b1 = y1, a2 = x2, b2 = y2;
if(dep[a1] < dep[b1])
swap(a1, b1);
if(dep[a2] < dep[b2])
swap(a2, b2);
int a = getLca(a1, a2);
int b = dep[b1] > dep[b2] ? b1 : b2;
if(dep[a] <= dep[b])
return 0;
if(way(x1, y1) == way(x2, y2)) {
auto tmp = getLongest(a, b);
int longDist = tmp.first;
int longest = tmp.second;
if(dep[x1] > dep[y1]) {
t1 += getDist(x1, longest);
t2 += getDist(x2, longest);
ll out1 = t1 + longDist;
ll out2 = t2 + longDist;
if(out2 <= t1 or out1 <= t2)
return 0;
return 1;
}
else {
t1 += getDist(x1, longest) - longDist;
t2 += getDist(x2, longest) - longDist;
ll out1 = t1 + longDist;
ll out2 = t2 + longDist;
if(out2 <= t1 or out1 <= t2)
return 0;
return 1;
}
}
else {
if(dep[x1] < dep[y1]) {
swap(x1, x2);
swap(y1, y2);
swap(t1, t2);
}
t1 += getDist(x1, a);
t2 += getDist(x2, b);
ll out1 = t1 + getDist(a, b);
ll out2 = t2 + getDist(a, b);
if(out2 <= t1 or out1 <= t2)
return 0;
for(int i = LOG - 1; i >= 0; i--) {
if(dep[a] - (1 << i) >= dep[b]) {
ll d = getDist(a, lca[i][a]);
if(t1 + d <= out2 - d) {
t1 += d;
out2 -= d;
a = lca[i][a];
}
}
}
return t1 != out2;
}
return 0;
}
int main () {
scanf("%d %d", &n, &q);
for(int i = 1; i < n; i++) {
int x, y, c;
scanf("%d %d %d", &x, &y, &c);
v[x].push_back({y, c});
v[y].push_back({x, c});
}
dfs(0, 1);
for(int i = 1; i <= q; i++) {
int x1, y1, x2, y2;
ll t1, t2;
scanf("%d %d %lld %d %d %lld", &x1, &y1, &t1, &x2, &y2, &t2);
int l1 = getLca(x1, y1), l2 = getLca(x2, y2);
bool res = 0;
res |= check(x1, l1, t1, x2, l2, t2);
res |= check(x1, l1, t1, l2, y2, t2 + to[x2] - to[l2]);
res |= check(l1, y1, t1 + to[x1] - to[l1], x2, l2, t2);
res |= check(l1, y1, t1 + to[x1] - to[l1], l2, y2, t2 + to[x2] - to[l2]);
puts(res ? "YES" : "NO");
}
return 0;
}
I2luY2x1ZGUgImlvc3RyZWFtIgojaW5jbHVkZSAiYWxnb3JpdGhtIgojaW5jbHVkZSAidmVjdG9yIgojaW5jbH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gfQp9CgppbnQgZ2V0TGNhKGludCB4LCBpbnQgeSkgewogICAgaWYoZGVwW3hdIDwgZGVwW3ldKQogICAgICAgIHN3YXAoeCwgeSk7CiAgICBmb3IoaW50IGkgPSBMT0cgLSAxOyBpID49IDA7IGktLSkKICAgICAgICBpZihkZXBbeF0gLSAoMSA8PCBpKSA+PSBkZXBbeV0pCiAgICAgICAgICAgIHggPSBsY2FbaV1beF07CiAgICBpZih4ID09IHkpCiAgICAgICAgcmV0dXJuIHg7CiAgICBmb3IoaW50IGkgPSBMT0cgLSAxOyBpID49IDA7IGktLSkgewogICAgICAgIGlmKGxjYVtpXVt4XSAhPSBsY2FbaV1beV0pIHsKICAgICAgICAgICAgeCA9IGxjYVtpXVt4XSwgeSA9IGxjYVtpXVt5XTsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gbGNhWzBdW3hdOwp9CgppaSBnZXRMb25nZXN0KGludCB4LCBpbnQgeSkgewogICAgaWYoZGVwW3hdIDwgZGVwW3ldKQogICAgICAgIHN3YXAoeCwgeSk7CiAgICBpaSByZXMgPSB7MCwgMH07CiAgICBmb3IoaW50IGkgPSBMT0cgLSAxOyBpID49IDA7IGktLSkgewogICAgICAgIGlmKGRlcFt4XSAtICgxIDw8IGkpID49IGRlcFt5XSkgewogICAgICAgICAgICByZXMgPSBtYXgocmVzLCBlZGdlW2ldW3hdKTsKICAgICAgICAgICAgeCA9IGxjYVtpXVt4XTsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gcmVzOwp9Cgpib29sIHdheShpbnQgeCwgaW50IHkpIHsKICAgIHJldHVybiBkZXBbeF0gPiBkZXBbeV07Cn0KCmxsIGdldERpc3QoaW50IHgsIGludCB5KSB7CiAgICBpZihkZXBbeF0gPCBkZXBbeV0pCiAgICAgICAgc3dhcCh4LCB5KTsKICAgIHJldHVybiB0b1t4XSAtIHRvW3ldOwp9Cgpib29sIGNoZWNrKGludCB4MSwgaW50IHkxLCBsbCB0MSwgaW50IHgyLCBpbn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IC0gbG9uZ0Rpc3Q7CiAgICAgICAgICAgIGxsIG91dDEgPSB0MSArIGxvbmdEaXN0OwogICAgICAgICAgICBsbCBvdXQyID0gdDIgKyBsb25nRGlzdDsKICAgICAgICAgICAgaWYob3V0MiA8PSB0MSBvciBvdXQxIDw9IHQyKQogICAgICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgICAgIHJldHVybiAxOwogICAgICAgIH0KICAgIH0KICAgIGVsc2UgewogICAgICAgIGlmKGRlcFt4MV0gPCBkZXBbeTFdKSB7CiAgICAgICAgICAgIHN3YXAoeDEsIHgyKTsKICAgICAgICAgICAgc3dhcCh5MSwgeTIpOwogICAgICAgICAgICBzd2FwKHQxLCB0Mik7CiAgICAgICAgfQogICAgICAgIHQxICs9IGdldERpc3QoeDEsIGEpOwogICAgICAgIHQyICs9IGdldERpc3QoeDIsIGIpOwogICAgICAgIGxsIG91dDEgPSB0MSArIGdldERpc3QoYSwgYik7CiAgICAgICAgbGwgb3V0MiA9IHQyICsgZ2V0RGlzdChhLCBiKTsKICAgICAgICBpZihvdXQyIDw9IHQxIG9yIG91dDEgPD0gdDIpCiAgICAgICAgICAgIHJldHVybiAwOwogICAgICAgIGZvcihpbnQgaSA9IExPRyAtIDE7IGkgPj0gMDsgaS0tKSB7CiAgICAgICAgICAgIGlmKGRlcFthXSAtICgxIDw8IGkpID49IGRlcFtiXSkgewogICAgICAgICAgICAgICAgbGwgZCA9IGdldERpc3QoYSwgbGNhW2ldW2FdKTsKICAgICAgICAgICAgICAgIGlmKHQxICsgZCA8PSBvdXQyIC0gZCkgewogICAgICAgICAgICAgICAgICAgIHQxICs9IGQ7CiAgICAgICAgICAgICAgICAgICAgb3V0MiAtPSBkOwogICAgICAgICAgICAgICAgICAgIGEgPSBsY2FbaV1bYV07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIHQxICE9IG91dDI7CiAgICB9CiAgICByZXR1cm4gMDsKf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