题目名称 2344. pair-pair
输入输出 pair-pair.in/out
难度等级 ★★★☆
时间限制 1000 ms (1 s)
内存限制 64 MiB
测试数据 10
题目来源 GravatarTenderRun 于2016-06-14加入
开放分组 全部用户
提交状态
分类标签
分享题解
通过:1, 提交:1, 通过率:100%
GravatarTenderRun 100 0.190 s 24.00 MiB C++
关于 pair-pair 的近10条评论(全部评论)
随机数据,有误请勿打我……
GravatarTenderRun
2016-06-15 18:40 2楼
读不懂题
GravatarHzoi_
2016-06-15 09:21 1楼

2344. pair-pair

★★★☆   输入文件:pair-pair.in   输出文件:pair-pair.out   简单对比
时间限制:1 s   内存限制:64 MiB

Time Limit : 1000 MS 

Memory Limit : 65536 KB


Pair-Pair

Bobo is tired of all kinds of hard LIS (Longest Increasing Subsequence) problems, so he decides to make himself some easier one.

Bobo has n pairs (a1,b1),(a2,b2),…,(an,bn) where 1≤ai,bi≤m holds for all i. He defines f(i,j) be the length of longest increasing subsequence of sequence {ai,bi,aj,bj}.

It's clear that 1≤f(i,j)≤4. Bobo would like to know g(k) which is the number of pairs (i,j) where f(i,j)=k.

Note that a sequence labeled with {i1,i2,…,ik} is an increasing subsequence of {a1,a2,…,an} only if:

1≤i1<i2<⋯<ik≤nai1<ai2<⋯<aik

Input

The first line contains 2 integers n,m (1≤n≤105,1≤m≤103).

The i-th of the following n lines contains 2 integers ai,bi (1≤ai,bi≤m).

Output

For each set, 4 integers g(1),g(2),g(3),g(4).

Sample Input


2 4

1 2

3 4

2 1

1 1

1 1



Sample Output


0 3 0 1

4 0 0 0