#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define INF int(1e9)
using namespace std;
const int N = 4e5 + 7;
typedef long long LL;
// k 好像没什么用qwq
int n, k;
int w = 2e5;
int tr[N];
inline int lowbit(int x){
return x & -x;
}
inline void update(int x,int v){
for(int i = x;i <= w;i += lowbit(i))
tr[i] += v;
}
inline int query(int x){
int ans = 0;
for(int i = x;i;i -= lowbit(i))
ans += tr[i];
return ans;
}
struct Node{
int op, a, b, c, id;
bool operator < (const Node& n1) const{
if(b == n1.b) return op < n1.op;
else return b < n1.b;
}
}q[N], tmp[N];
int ans[N], d[N];
void solve(int l,int r){
if(l == r) return ;
int mid = l + r >> 1;
solve(l, mid);
sort(q + l, q + 1 + r);
for(int i = l;i <= r;i ++ ){
if(q[i].op == 1 && q[i].a <= mid) update(q[i].c, 1);
if(q[i].op == 2 && q[i].a >= mid + 1){
ans[q[i].id] += query(q[i].c);
}
}
// clear
for(int i = l;i <= r;i ++ ){
if(q[i].op == 1 && q[i].a <= mid)
update(q[i].c, -1);
}
for(int i = l;i <= r;i ++ ) q[i] = tmp[i];
solve(mid + 1, r);
}
int main(){
scanf("%d%d", &n, &k);
// insert - query
for(int i = 1;i <= n;i ++ ){
scanf("%d%d%d", &q[i].a, &q[i].b, &q[i].c);
q[i + n] = q[i];
q[i].op = 1, q[i + n].op = 2;
q[i].id = 0, q[i + n].id = i;
}
sort(q + 1, q + 1 + n * 2, [&](const Node& n1, const Node& n2){
if(n1.a == n2.a) return n1.op < n2.op;
else return n1.a < n2.a;
});
// 给一个 唯一 的 timestamp
for(int i = 1;i <= 2 * n;i ++ )
q[i].a = i;
memcpy(tmp, q, sizeof q);
solve(1, 2 * n);
for(int i = 1;i <= n;i ++ ) ++ d[ -- ans[i]];
for(int i = 0;i < n;i ++ ) printf("%d\n", d[i]);
return 0;
}