#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
const int inf = 0x7fffffff;
struct node
{
int to,cap,rev;
node() {}
node(int _to,int _cap,int _rev)
{
to = _to;
cap = _cap;
rev = _rev;
}
};
vector<node>G[maxn];
int level[maxn],iter[maxn];
void addedge(int u,int v,int cap)
{
G[u].push_back(node(v,cap,G[v].size()));
G[v].push_back(node(u,0,G[u].size()-1));
}
bool bfs(int s,int t)
{
memset(level,-1,sizeof(level));
level[s] = 0;
queue<int>q;
q.push(s);
while(!q.empty())
{
int v = q.front();
q.pop();
for(unsigned i = 0;i<G[v].size();i++)
{
node e = G[v][i];
if(level[e.to]<0 && e.cap>0)
{
level[e.to] = level[v]+1;
q.push(e.to);
}
}
}
return level[t] != -1;
}
int dfs(int v,int t,int f)
{
if(v==t) return f;
for(int &i = iter[v];i<(int)G[v].size();i++)
{
node &e = G[v][i];
if(level[e.to]>level[v] && e.cap>0)
{
int d = dfs(e.to,t,min(e.cap,f));
if(d>0)
{
e.cap -= d;
G[e.to][e.rev].cap += d;
return d;
}
}
}
return 0;
}
int max_flow(int s,int t)
{
int flow = 0,f;
while(bfs(s,t))
{
memset(iter,0,sizeof(iter));
while((f = dfs(s,t,inf))>0)
flow += f;
}
return flow;
}
int main(void)
{
int t,case_t = 1;
scanf("%d",&t);
while(t--)
{
for(int i=0;i<maxn;i++)
G[i].clear();
int n,m;
scanf("%d %d",&n,&m);
int ma = 0,mi = inf,sum = 0;
for(int i=1;i<=n;i++)
{
int p,s,e;
scanf("%d %d %d",&p,&s,&e);
addedge(0,i,p);
sum += p;
for(int j=s;j<=e;j++)
addedge(i,j+n,1);
mi = min(s,mi);
ma = max(e,ma);
}
int e = ma+500;
for(int i=mi;i<=ma;i++)
addedge(n+i,e,m);
int ans = max_flow(0,e);
printf("Case %d: ",case_t++);
if(ans==sum)
puts("Yes\n");
else
puts("No\n");
}
return 0;
}