#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<ctime>
#include<deque>
#include<list>
#include<stack>
#include<utility>
#include<climits>
#include<bitset>
#include<unordered_map>
#define FS fixed<<setprecision
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PiII pair<int,pair<int,int>>
#define BUG puts("===============")
#define endl '\n'
#define space ' '
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
using namespace std;
inline void putsp(ull x=1){for(ull i=1;i<=x;++i)putchar(' ');}
inline void nxtl(ull x=1){for(ull i=1;i<=x;++i)putchar('\n');}
const int MAXINT = 2147483647, INF = 0x3f3f3f3f;
const int MAXN = 2e5 + 10;
struct node{
int a, b, c, id;
bool operator < (const node& B) const {
if (a == B.a) {
if (b == B.b) return c < B.c;
return b < B.b;
}
return a < B.a;
}
bool operator == (const node& B) const {
return a == B.a && b == B.b && c == B.c;
}
node(const int& _a = 0, const int& _b = 0, const int& _c = 0, const int& _id = 0) {
a = _a, b = _b, c = _c, id = _id;
}
}tup[MAXN];
int n, maxv;
int tr[MAXN], val[MAXN];
int ans[MAXN], res[MAXN];
inline int lowbit(const int& x) {
return x & (-x);
}
inline void tr_add(const int& x, const int& val) {
for (int i = x; i <= n; i += lowbit(i))
tr[i] += val;
}
inline int tr_query(const int& x) {
int ret = 0;
for (int i = x; i; i -= lowbit(i))
ret += tr[i];
return ret;
}
inline void cdq(const int& l, const int& r) {
if (l == r) return;
int mid = l + r >> 1, i = l, j = mid + 1, cntt = 0;
cdq(l, mid), cdq(mid + 1, r);
node* temp = new node[r - l + 5];
while (i <= mid && j <= r) {
if (tup[i].b <= tup[j].b)
tr_add(tup[i].c, val[tup[i].id]), temp[++cntt] = tup[i++];
else
ans[tup[j].id] += tr_query(tup[j].c), temp[++cntt] = tup[j++];
}
while (i <= mid) tr_add(tup[i].c, val[tup[i].id]), temp[++cntt] = tup[i++];
while (j <= r) ans[tup[j].id] += tr_query(tup[j].c), temp[++cntt] = tup[j++];
for (int k = l; k <= mid; ++k) tr_add(tup[k].c, -val[tup[k].id]);
for (int k = 1; k <= cntt; ++k) tup[l + k - 1] = temp[k];
}
int main() {
cin >> n >> maxv;
for (int i = 1; i <= n; ++i) {
cin >> tup[i].a >> tup[i].b >> tup[i].c;
}
sort(tup + 1, tup + 1 + n);
int rid = 1;
for (int i = 2; i <= n; ++i) {
if (tup[rid] == tup[i]) ++val[rid];
else tup[++rid] = tup[i];
}
for (int i = 1; i <= rid; ++i)
tup[i].id = i, ++val[i];
cdq(1, rid);
for (int i = 1; i <= rid; ++i)
res[ans[tup[i].id] + val[tup[i].id] - 1] += val[tup[i].id];
for (int i = 0; i < n; ++i)
cout << res[i] << endl;
return 0;
}