#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define in4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define inp(p) in2(p.F,p.S)
#define llin(a) cin >> a
#define llin2(a,b) cin >> a >> b
#define llin3(a,b,c) cin >> a >> b >> c
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twodread(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define prp(p) pr2(p.F,p.S)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llpr2(a,b) cout << a << " " << b << " "
#define llout(a) cout << a << "\n"
#define pinttwod(mat,i,j,n,m) rep(i,n){rep(j,m)pr(mat[i][j]);   lin;}
#define plltwod(mat,i,j,n,m)  rep(i,n){rep(j,m)llpr(mat[i][j]); lin;}
#define byes printf("YES\n")
#define bno printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
#define test(q) cout << "Case #" << q << ": "
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define fone(i,n) for(i=1;i<=n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) (int)x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
#define middle() ((l+h)/2)
#define lchild(p) 2*p
#define rchild(p) 2*p+1
#define lseg l,m,2*p
#define rseg m+1,h,2*p+1
#define bhardo(mat,i,j,n,m,t) rep(i,n){rep(j,m)mat[i][j]=t;}
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
#define biton(mask,i)  ((mask>>i)&1)
#define bitoff(mask,i) (!((mask>>i)&1))
#define toggle(mask,i) (mask^=(1<<(i)))
#define mul(p,q) ((ll)(p)*(ll)(q))
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define lii pair<ll,ll>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e18;
const int M = (1e9)+7;
//const int M= 998244353;
const int N = (2e5)+3;  // check the limit, man
const int K = 19;
/**
 Have you worked on Simplification of Idea?
 Ok! let's code, check whether it is correct or not?
*/
vi suffix_array(string &str)
{
    int i,j,a,c,k,n=sz(str);
    int cnt[n];
    vi order(n),nxt(n),temp(n);
    vector<pair<ii,int> > ar(n);
    rep(i,n)
        ar[i]={{str[i]-str[n-1],0},i};
    sort(all(ar));
    for(k=1;k<2*n;k*=2)
    {
        i=0,j=0,c=0;
        while(i<n)
        {
            while(j<n && ar[i].F==ar[j].F)
                order[ar[j].S]=c,j++;
            i=j,c++;
        }
        if(c==n)
            break;
        a=(k<n?k:k-n);
        rep(i,n)
        {
            nxt[i]=a++;
            if(a>=n)a-=n;
        }
        fill(cnt,cnt+c,0);
        rep(i,n)
            ++cnt[order[i]];
        lp(i,1,c)
            cnt[i]+=cnt[i-1];
        rrep(i,n)
            a=nxt[ar[i].S],temp[--cnt[order[a]]]=ar[i].S;
        rep(i,n)
            a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
        fill(cnt,cnt+c,0);
        rep(i,n)
            ++cnt[order[i]];
        lp(i,1,c)
            cnt[i]+=cnt[i-1];
        rrep(i,n)
            a=ar[i].S,temp[--cnt[order[a]]]=ar[i].S;
        rep(i,n)
            a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
    }
    vi v(n);
    rep(i,n)
        v[i]=ar[i].S;
    return v;
}
vi lcp_construction(string &str,vi &v)
{
    int n=sz(str);
    int i,j;
    vi pos(n,0);
    rep(i,n)
        pos[v[i]]=i;
    vi lcp(n-1,0);
    int k=0;
    rep(i,n)
    {
        if(pos[i]==n-1)
        {
            k=0;
            continue;
        }
        j=v[pos[i]+1];
        while(i+k<n && j+k<n && str[i+k]==str[j+k])
            k++;
        lcp[pos[i]]=k;
        if(k)
            k--;
    }
    return lcp;
}
struct wavelet_tree
{
    vvi cnt;
    int s;
    typedef vector<int>::iterator itr;
    // sigma = size of alphabet, convert element into range [0,sigma-1]
    // sigma is one more than max_element of array
    // time complexity O(sigma*log2(sigma))
    void initialize(vi &v,int sigma)
    {
        cnt.resize(2*sigma);
        s=sigma;
        build(v.begin(),v.end(),0,s-1,1);
    }
    void build(itr b,itr e,int l,int h,int p)
    {
        if(l==h)
            return ;
        int m=middle();
        cnt[p].reserve(e-b+1);
        cnt[p].pb(0);
        for(itr cur=b;cur!=e;++cur)
            cnt[p].pb(cnt[p].back()+(*cur<=m));
        itr mid=stable_partition(b,e,[=](int i){return i<=m;});
        build(b,mid,l,m,lchild(p));
        build(mid,e,m+1,h,rchild(p));
    }
    int orderofkey(int a,int b,int k) // count number of element<=k in [a,b) 0-indexing
    {
        int l=0,h=s-1,p=1;
        int ans=0,m;
        int ra,rb;
        while(l<h)
        {
            m=middle();
            ra=cnt[p][a],rb=cnt[p][b];
            if(k<=m)
                a=ra,b=rb,h=m,p=lchild(p);
            else
                ans+=(rb-ra),a-=ra,b-=rb,l=m+1,p=rchild(p);
        }
        return ans+(b-a);
    }
};
struct distinct
{
    wavelet_tree ar;
    // element of array must be in range [0,n] where n is size of array
    distinct(vi &v)
    {
        int i,a,n=sz(v);
        vi last(n+1,-1);
        vi pos_next(n,n);
        rep(i,n)
        {
            a=v[i];
            if(last[a]>=0)
                pos_next[last[a]]=i;
            last[a]=i;
        }
        ar.initialize(pos_next,n+1);
    }
    int query(int a,int b) // number of distinct element in [a,b] 0-indexing
    {
        return b-a+1-ar.orderofkey(a,b+1,b);
    }
};
struct sparse
{
    int sp[N][K];
    int po[K],ar[2*N];
    sparse()
    {
        int i,k;
        ar[1]=0,k=1,po[0]=1;
        while(k<N)
        {
            for(i=k+1;i<2*k;i++)
                ar[i]=ar[k];
            ar[2*k]=1+ar[k],k*=2;
        }
        for(i=1;i<K;i++)
            po[i]=2*po[i-1];
    }
    int operation(int a,int b)
    {
        return min(a,b);
    }
    void build(vi &val)
    {
        int i,k,n=sz(val);
        rrep(i,n)
        {
            sp[i][0]=val[i];
            for(k=1;i+po[k]<=n;k++)
                sp[i][k]=operation(sp[i][k-1],sp[i+po[k-1]][k-1]);
        }
    }
    int query(int a,int b)
    {
        if(a>b)
            return 0;
        int y,x=b-a+1;
        y=ar[x],x-=po[y];
        return operation(sp[a][y],sp[a+x][y]);
    }
};
int num[N],aage[N];
void solve()
{
    int n,i,j,k;
    in2(n,k);
    vector<string> word(n);
    string str;
    rep(i,n)
        llin(word[i]),word[i]+='$',str+=word[i];
    if(k==1 || k>n)
    {
        if(k==1)
        {
            rep(i,n)
                j=sz(word[i]),llpr(mul(j,j-1)/2);
        }
        if(k>n)
            rep(i,n)pr(0);
        lin,exit(0);
    }
    auto v = suffix_array(str);
    auto lcp = lcp_construction(str,v);
    lcp.pb(0);
    rep(i,n)
        v.erase(v.begin()),lcp.erase(lcp.begin());
    int len=sz(str);
    int x=0,last=-1;
    rep(i,len)
    {
        num[i]=x;
        aage[i]=sz(word[x])-(i-last);
        if(str[i]=='$')
            x++,last=i;
    }
    vi ar;
    for(auto a : v)
        ar.pb(num[a]);
    distinct number(ar);
    vector<ll> ans(n,0);
    sparse rmq;
    rmq.build(lcp);
    len-=n;
    int l,h,m,a,p;
    rep(i,len)
    {
        l=0,h=aage[v[i]];
        while(l<h)
        {
            m=(l+h+1)/2;
            x=i;
            rrep(j,K)
            {
                a=(1<<j);
                if(x-a>=0 && rmq.query(x-a,x-1)>=m)
                    x-=a;
            }
            p=x;
            rrep(j,K)
            {
                a=(1<<j);
                if(x+a-1<len && rmq.query(x,x+a-1)>=m)
                    x+=a;
            }
            if(number.query(p,x)>=k)
                l=m;
            else
                h=m-1;
        }
//        pr2(v[i],l);
        ans[num[v[i]]]+=l;
    }
    rep(i,n)
        llpr(ans[i]);
    lin;
}
int main()
{
    int t=1;
    //in(t);
    while(t--)
        solve();
}


#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define in4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define inp(p) in2(p.F,p.S)
#define llin(a) cin >> a
#define llin2(a,b) cin >> a >> b
#define llin3(a,b,c) cin >> a >> b >> c
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twodread(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define prp(p) pr2(p.F,p.S)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llpr2(a,b) cout << a << " " << b << " "
#define llout(a) cout << a << "\n"
#define pinttwod(mat,i,j,n,m) rep(i,n){rep(j,m)pr(mat[i][j]);   lin;}
#define plltwod(mat,i,j,n,m)  rep(i,n){rep(j,m)llpr(mat[i][j]); lin;}
#define byes printf("YES\n")
#define bno printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
#define test(q) cout << "Case #" << q << ": "
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define fone(i,n) for(i=1;i<=n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) (int)x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
#define middle() ((l+h)/2)
#define lchild(p) 2*p
#define rchild(p) 2*p+1
#define lseg l,m,2*p
#define rseg m+1,h,2*p+1
#define bhardo(mat,i,j,n,m,t) rep(i,n){rep(j,m)mat[i][j]=t;}
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
#define biton(mask,i)  ((mask>>i)&1)
#define bitoff(mask,i) (!((mask>>i)&1))
#define toggle(mask,i) (mask^=(1<<(i)))
#define mul(p,q) ((ll)(p)*(ll)(q))
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define lii pair<ll,ll>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e18;
const int M = (1e9)+7;
//const int M= 998244353;
const int N = (2e5)+3;  // check the limit, man
const int K = 19;
/**
 Have you worked on Simplification of Idea?
 Ok! let's code, check whether it is correct or not?
*/
vi suffix_array(string &str)
{
    int i,j,a,c,k,n=sz(str);
    int cnt[n];
    vi order(n),nxt(n),temp(n);
    vector<pair<ii,int> > ar(n);
    rep(i,n)
        ar[i]={{str[i]-str[n-1],0},i};
    sort(all(ar));
    for(k=1;k<2*n;k*=2)
    {
        i=0,j=0,c=0;
        while(i<n)
        {
            while(j<n && ar[i].F==ar[j].F)
                order[ar[j].S]=c,j++;
            i=j,c++;
        }
        if(c==n)
            break;
        a=(k<n?k:k-n);
        rep(i,n)
        {
            nxt[i]=a++;
            if(a>=n)a-=n;
        }
        fill(cnt,cnt+c,0);
        rep(i,n)
            ++cnt[order[i]];
        lp(i,1,c)
            cnt[i]+=cnt[i-1];
        rrep(i,n)
            a=nxt[ar[i].S],temp[--cnt[order[a]]]=ar[i].S;
        rep(i,n)
            a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
        fill(cnt,cnt+c,0);
        rep(i,n)
            ++cnt[order[i]];
        lp(i,1,c)
            cnt[i]+=cnt[i-1];
        rrep(i,n)
            a=ar[i].S,temp[--cnt[order[a]]]=ar[i].S;
        rep(i,n)
            a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
    }
    vi v(n);
    rep(i,n)
        v[i]=ar[i].S;
    return v;
}
vi lcp_construction(string &str,vi &v)
{
    int n=sz(str);
    int i,j;
    vi pos(n,0);
    rep(i,n)
        pos[v[i]]=i;
    vi lcp(n-1,0);
    int k=0;
    rep(i,n)
    {
        if(pos[i]==n-1)
        {
            k=0;
            continue;
        }
        j=v[pos[i]+1];
        while(i+k<n && j+k<n && str[i+k]==str[j+k])
            k++;
        lcp[pos[i]]=k;
        if(k)
            k--;
    }
    return lcp;
}
struct wavelet_tree
{
    vvi cnt;
    int s;
    typedef vector<int>::iterator itr;
    // sigma = size of alphabet, convert element into range [0,sigma-1]
    // sigma is one more than max_element of array
    // time complexity O(sigma*log2(sigma))
    void initialize(vi &v,int sigma)
    {
        cnt.resize(2*sigma);
        s=sigma;
        build(v.begin(),v.end(),0,s-1,1);
    }
    void build(itr b,itr e,int l,int h,int p)
    {
        if(l==h)
            return ;
        int m=middle();
        cnt[p].reserve(e-b+1);
        cnt[p].pb(0);
        for(itr cur=b;cur!=e;++cur)
            cnt[p].pb(cnt[p].back()+(*cur<=m));
        itr mid=stable_partition(b,e,[=](int i){return i<=m;});
        build(b,mid,l,m,lchild(p));
        build(mid,e,m+1,h,rchild(p));
    }
    int orderofkey(int a,int b,int k) // count number of element<=k in [a,b) 0-indexing
    {
        int l=0,h=s-1,p=1;
        int ans=0,m;
        int ra,rb;
        while(l<h)
        {
            m=middle();
            ra=cnt[p][a],rb=cnt[p][b];
            if(k<=m)
                a=ra,b=rb,h=m,p=lchild(p);
            else
                ans+=(rb-ra),a-=ra,b-=rb,l=m+1,p=rchild(p);
        }
        return ans+(b-a);
    }
};
struct distinct
{
    wavelet_tree ar;
    // element of array must be in range [0,n] where n is size of array
    distinct(vi &v)
    {
        int i,a,n=sz(v);
        vi last(n+1,-1);
        vi pos_next(n,n);
        rep(i,n)
        {
            a=v[i];
            if(last[a]>=0)
                pos_next[last[a]]=i;
            last[a]=i;
        }
        ar.initialize(pos_next,n+1);
    }
    int query(int a,int b) // number of distinct element in [a,b] 0-indexing
    {
        return b-a+1-ar.orderofkey(a,b+1,b);
    }
};
struct sparse
{
    int sp[N][K];
    int po[K],ar[2*N];
    sparse()
    {
        int i,k;
        ar[1]=0,k=1,po[0]=1;
        while(k<N)
        {
            for(i=k+1;i<2*k;i++)
                ar[i]=ar[k];
            ar[2*k]=1+ar[k],k*=2;
        }
        for(i=1;i<K;i++)
            po[i]=2*po[i-1];
    }
    int operation(int a,int b)
    {
        return min(a,b);
    }
    void build(vi &val)
    {
        int i,k,n=sz(val);
        rrep(i,n)
        {
            sp[i][0]=val[i];
            for(k=1;i+po[k]<=n;k++)
                sp[i][k]=operation(sp[i][k-1],sp[i+po[k-1]][k-1]);
        }
    }
    int query(int a,int b)
    {
        if(a>b)
            return 0;
        int y,x=b-a+1;
        y=ar[x],x-=po[y];
        return operation(sp[a][y],sp[a+x][y]);
    }
};
int num[N],aage[N];
void solve()
{
    int n,i,j,k;
    in2(n,k);
    vector<string> word(n);
    string str;
    rep(i,n)
        llin(word[i]),word[i]+='$',str+=word[i];
    if(k==1 || k>n)
    {
        if(k==1)
        {
            rep(i,n)
                j=sz(word[i]),llpr(mul(j,j-1)/2);
        }
        if(k>n)
            rep(i,n)pr(0);
        lin,exit(0);
    }
    auto v = suffix_array(str);
    auto lcp = lcp_construction(str,v);
    lcp.pb(0);
    rep(i,n)
        v.erase(v.begin()),lcp.erase(lcp.begin());
    int len=sz(str);
    int x=0,last=-1;
    rep(i,len)
    {
        num[i]=x;
        aage[i]=sz(word[x])-(i-last);
        if(str[i]=='$')
            x++,last=i;
    }
    vi ar;
    for(auto a : v)
        ar.pb(num[a]);
    distinct number(ar);
    vector<ll> ans(n,0);
    sparse rmq;
    rmq.build(lcp);
    len-=n;
    int l,h,m,a,p;
    rep(i,len)
    {
        l=0,h=aage[v[i]];
        while(l<h)
        {
            m=(l+h+1)/2;
            x=i;
            rrep(j,K)
            {
                a=(1<<j);
                if(x-a>=0 && rmq.query(x-a,x-1)>=m)
                    x-=a;
            }
            p=x;
            rrep(j,K)
            {
                a=(1<<j);
                if(x+a<len && rmq.query(x,x+a)>=m)
                    x+=a;
            }
            if(x>p)
                x++;
            if(number.query(p,x)>=k)
                l=m;
            else
                h=m-1;
        }
        ans[num[v[i]]]+=l;
    }
    rep(i,n)
        llpr(ans[i]);
    lin;
}
int main()
{
    int t=1;
    //in(t);
    while(t--)
        solve();
}


#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define in4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define inp(p) in2(p.F,p.S)
#define llin(a) cin >> a
#define llin2(a,b) cin >> a >> b
#define llin3(a,b,c) cin >> a >> b >> c
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twodread(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define prp(p) pr2(p.F,p.S)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llpr2(a,b) cout << a << " " << b << "\n"
#define llout(a) cout << a << "\n"
#define pinttwod(mat,i,j,n,m) rep(i,n){rep(j,m)pr(mat[i][j]);   lin;}
#define plltwod(mat,i,j,n,m)  rep(i,n){rep(j,m)llpr(mat[i][j]); lin;}
#define byes printf("YES\n")
#define bno printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
#define test(q) cout << "Case #" << q << ": "
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define fone(i,n) for(i=1;i<=n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) (int)x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
#define middle() ((l+h)/2)
#define lchild(p) 2*p
#define rchild(p) 2*p+1
#define lseg l,m,2*p
#define rseg m+1,h,2*p+1
#define bhardo(mat,i,j,n,m,t) rep(i,n){rep(j,m)mat[i][j]=t;}
#define baselog2(n) __lg(n)
#define numberofbit(n) (32-__builtin_clz(n))
#define numberofbitll(n) (64-__builtin_clzll(n))
#define onbitcount(x)  __builtin_popcount(x)
#define onbitcountll(x)  __builtin_popcountll(x)
#define biton(mask,i)  ((mask>>i)&1)
#define bitoff(mask,i) (!((mask>>i)&1))
#define toggle(mask,i) (mask^=(1<<(i)))
#define raise(i) (1<<(i))
#define mul(p,q) ((ll)(p)*(ll)(q))
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define lii pair<ll,ll>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e18;
const int M = (1e9)+7;
//const int M= 998244353;
const int N = (2e5)+3;  // check the limit, man
/**
 Have you worked on Simplification of Idea?
 Ok! let's code, check whether it is correct or not?
*/
struct suffix_array
{
    vi v;           // store suffix array
    vi pos;         // store position of suffix from i in suffix array
    vi lcp;         // lcp array of size n with last value 0
    vvi sp;         // sparse table of lcp array of size n
    string str;     // string after adding last char
    int n;          // size of string after adding last char
    void build(string &cur)         // don't need to add last char manually
    {
        int ch=31;
        cur+=ch;
        str=cur;
        int i,j,a,c,k;
        n=sz(str);
        vi order(n),nxt(n),temp(n),cnt(n);
        vector<pair<ii,int> > ar(n);
        rep(i,n)ar[i]={{str[i]-str[n-1],0},i};
        sort(all(ar));
        for(k=1;k<2*n;k*=2)
        {
            i=0,j=0,c=0;
            while(i<n)
            {
                while(j<n && ar[i].F==ar[j].F)order[ar[j].S]=c,j++;
                i=j,c++;
            }
            if(c==n)
                break;
            a=(k<n?k:k-n);
            rep(i,n)
            {
                nxt[i]=a++;
                if(a>=n)a-=n;
            }
            rep(i,c)cnt[i]=0;
            rep(i,n)++cnt[order[i]];
            lp(i,1,c)cnt[i]+=cnt[i-1];
            rrep(i,n)a=nxt[ar[i].S],temp[--cnt[order[a]]]=ar[i].S;
            rep(i,n)a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
            rep(i,c)cnt[i]=0;
            rep(i,n)++cnt[order[i]];
            lp(i,1,c)cnt[i]+=cnt[i-1];
            rrep(i,n)a=ar[i].S,temp[--cnt[order[a]]]=ar[i].S;
            rep(i,n)a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
        }
        v.resize(n);
        pos.resize(n);
        rep(i,n)
            v[i]=ar[i].S,pos[v[i]]=i;
        return lcp_construction();
    }
    void lcp_construction()
    {
        lcp.resize(n,0);
        int i,j,k=0;
        rep(i,n)
        {
            if(pos[i]==n-1)
            {
                k=0;
                continue;
            }
            j=v[pos[i]+1];
            while(i+k<n && j+k<n && str[i+k]==str[j+k])
                k++;
            lcp[pos[i]]=k;
            if(k)
                k--;
        }
        return build_sparsetable();
    }
    void build_sparsetable()
    {
        int i,k;
        sp.resize(n,vi (numberofbit(n),0));
        rrep(i,n)
        {
            sp[i][0]=lcp[i];
            for(k=1;i+raise(k)<=n;k++)
                sp[i][k]=min(sp[i][k-1],sp[i+raise(k-1)][k-1]);
        }
        return ;
    }
    int lowerbound(string &temp)    // lowerbound index of some string
    {
        int m,l=0,r=n;
        while(l<r)
        {
            m=(l+r)/2;
            if(str.substr(v[m],min(sz(temp),n-v[m]))<temp)
                l=m+1;
            else
                r=m;
        }
        return l;
    }
    int upperbound(string &temp)    // upperbound index of some string
    {
        int m,l=0,r=n;
        while(l<r)
        {
            m=(l+r)/2;
            if(str.substr(v[m],min(sz(temp),n-v[m]))<=temp)
                l=m+1;
            else
                r=m;
        }
        return l;
    }
    int query(int a,int b)          // return min in [a,b] in lcp array or length of suffix if(b==a-1);
    {
        if(b==a-1)
            return n-v[a];
        int y,x=b-a+1;
        y=baselog2(x),x-=raise(y);
        return min(sp[a][y],sp[a+x][y]);
    }
    int common_prefix(int a,int b)  // lcp of two suffix start from a and b(a<n && b<n)
    {
        a=pos[a],b=pos[b];
        if(a>b)
            swap(a,b);
        return query(a,b-1);
    }
    int first_occurence(int k,int m)// first occurrence of suffix start from k of length m
    {
        int i,p=pos[k];
        rrep(i,numberofbit(n))
            if(p-raise(i)>=0 && sp[p-raise(i)][i]>=m)p-=raise(i);
        return p;
    }
    int last_occurence(int k,int m) // last  occurrence of suffix start from k of length m
    {
        int i,p=pos[k];
        rrep(i,numberofbit(n))
            if(p+raise(i)<=n && sp[p][i]>=m)p+=raise(i);
        return p;
    }
};
struct wavelet_tree
{
    vvi cnt;
    int s;
    typedef vector<int>::iterator itr;
    // sigma = size of alphabet, convert element into range [0,sigma-1]
    // sigma is one more than max_element of array
    // time complexity O(sigma*log2(sigma))
    void initialize(vi &v,int sigma)
    {
        cnt.resize(2*sigma);
        s=sigma;
        build(v.begin(),v.end(),0,s-1,1);
    }
    void build(itr b,itr e,int l,int h,int p)
    {
        if(l==h)
            return ;
        int m=middle();
        cnt[p].reserve(e-b+1);
        cnt[p].pb(0);
        for(itr cur=b;cur!=e;++cur)
            cnt[p].pb(cnt[p].back()+(*cur<=m));
        itr mid=stable_partition(b,e,[=](int i){return i<=m;});
        build(b,mid,l,m,lchild(p));
        build(mid,e,m+1,h,rchild(p));
    }
    int orderofkey(int a,int b,int k) // count number of element<=k in [a,b) 0-indexing
    {
        int l=0,h=s-1,p=1;
        int ans=0,m;
        int ra,rb;
        while(l<h)
        {
            m=middle();
            ra=cnt[p][a],rb=cnt[p][b];
            if(k<=m)
                a=ra,b=rb,h=m,p=lchild(p);
            else
                ans+=(rb-ra),a-=ra,b-=rb,l=m+1,p=rchild(p);
        }
        return ans+(b-a);
    }
};
struct distinct
{
    wavelet_tree ar;
    // element of array must be in range [0,n] where n is size of array
    distinct(vi &v)
    {
        int i,a,n=sz(v);
        vi last(n+1,-1);
        vi pos_next(n,n);
        rep(i,n)
        {
            a=v[i];
            if(last[a]>=0)
                pos_next[last[a]]=i;
            last[a]=i;
        }
        ar.initialize(pos_next,n+1);
    }
    int query(int a,int b) // number of distinct element in [a,b] 0-indexing
    {
        return b-a+1-ar.orderofkey(a,b+1,b);
    }
};
int num[N],aage[N];
void solve()
{
    int n,i,k;
    in2(n,k);
    vector<string> word(n);
    string str;
    rep(i,n)
        llin(word[i]),word[i]+='0',str+=word[i];
    int len=sz(str);
    suffix_array sa;
    sa.build(str);
    auto v = sa.v;
    reverse(all(v));
    v.resize(len-n);
    reverse(all(v));
    int x=0,last=-1;
    rep(i,len)
    {
        num[i]=x;
        aage[i]=sz(word[x])-(i-last);
        if(str[i]=='0')
            x++,last=i;
    }
    vi ar;
    for(auto a : v)
        ar.pb(num[a]);
    distinct number(ar);
    vector<ll> ans(n,0);
    int l,h,m,p,q;
    rep(i,len)
    {
        if(str[i]=='0')
            continue;
        l=0,h=aage[i];
        while(l<h)
        {
            m=(l+h+1)/2;
            p=sa.first_occurence(i,m)-n-1;
            q=sa.last_occurence(i,m)-n-1;
            if(number.query(p,q)>=k)
                l=m;
            else
                h=m-1;
        }
        ans[num[i]]+=l;
    }
    rep(i,n)
        llpr(ans[i]);
    lin;
}
int main()
{
    int t=1;
    //in(t);
    while(t--)
        solve();
}


#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define in4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define inp(p) in2(p.F,p.S)
#define llin(a) cin >> a
#define llin2(a,b) cin >> a >> b
#define llin3(a,b,c) cin >> a >> b >> c
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twodread(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define prp(p) pr2(p.F,p.S)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llpr2(a,b) cout << a << " " << b << "\n"
#define llout(a) cout << a << "\n"
#define pinttwod(mat,i,j,n,m) rep(i,n){rep(j,m)pr(mat[i][j]);   lin;}
#define plltwod(mat,i,j,n,m)  rep(i,n){rep(j,m)llpr(mat[i][j]); lin;}
#define byes printf("YES\n")
#define bno printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
#define test(q) cout << "Case #" << q << ": "
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define fone(i,n) for(i=1;i<=n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) (int)x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
#define middle() ((l+h)/2)
#define lchild(p) 2*p
#define rchild(p) 2*p+1
#define lseg l,m,2*p
#define rseg m+1,h,2*p+1
#define bhardo(mat,i,j,n,m,t) rep(i,n){rep(j,m)mat[i][j]=t;}
#define baselog2(n) __lg(n)
#define numberofbit(n) (32-__builtin_clz(n))
#define numberofbitll(n) (64-__builtin_clzll(n))
#define onbitcount(x)  __builtin_popcount(x)
#define onbitcountll(x)  __builtin_popcountll(x)
#define biton(mask,i)  ((mask>>i)&1)
#define bitoff(mask,i) (!((mask>>i)&1))
#define toggle(mask,i) (mask^=(1<<(i)))
#define raise(i) (1<<(i))
#define mul(p,q) ((ll)(p)*(ll)(q))
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define lii pair<ll,ll>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e18;
const int M = (1e9)+7;
//const int M= 998244353;
const int N = (2e5)+3;  // check the limit, man
/**
 Have you worked on Simplification of Idea?
 Ok! let's code, check whether it is correct or not?
*/
struct suffix_array
{
    vi v;           // store suffix array
    vi pos;         // store position of suffix from i in suffix array
    vi lcp;         // lcp array of size n with last value 0
    vvi sp;         // sparse table of lcp array of size n
    string str;     // string after adding last char
    int n;          // size of string after adding last char
    int bit;        // numberofbit(n)
    void build(string &cur)         // don't need to add last char manually
    {
        int ch=31;
        cur+=ch;
        str=cur;
        n=sz(str);
        bit=numberofbit(n);
        int i,j,a,c,k;
        vi order(n),nxt(n),temp(n),cnt(n);
        vector<pair<ii,int> > ar(n);
        rep(i,n)ar[i]={{str[i]-str[n-1],0},i};
        sort(all(ar));
        for(k=1;k<2*n;k*=2)
        {
            i=0,j=0,c=0;
            while(i<n)
            {
                while(j<n && ar[i].F==ar[j].F)order[ar[j].S]=c,j++;
                i=j,c++;
            }
            if(c==n)
                break;
            a=(k<n?k:k-n);
            rep(i,n)
            {
                nxt[i]=a++;
                if(a>=n)a-=n;
            }
            rep(i,c)cnt[i]=0;
            rep(i,n)++cnt[order[i]];
            lp(i,1,c)cnt[i]+=cnt[i-1];
            rrep(i,n)a=nxt[ar[i].S],temp[--cnt[order[a]]]=ar[i].S;
            rep(i,n)a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
            rep(i,c)cnt[i]=0;
            rep(i,n)++cnt[order[i]];
            lp(i,1,c)cnt[i]+=cnt[i-1];
            rrep(i,n)a=ar[i].S,temp[--cnt[order[a]]]=ar[i].S;
            rep(i,n)a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
        }
        v.resize(n);
        pos.resize(n);
        rep(i,n)
            v[i]=ar[i].S,pos[v[i]]=i;
        return lcp_construction();
    }
    void lcp_construction()
    {
        lcp.resize(n,0);
        int i,j,k=0;
        rep(i,n)
        {
            if(pos[i]==n-1)
            {
                k=0;
                continue;
            }
            j=v[pos[i]+1];
            while(i+k<n && j+k<n && str[i+k]==str[j+k])
                k++;
            lcp[pos[i]]=k;
            if(k)
                k--;
        }
        return build_sparsetable();
    }
    void build_sparsetable()
    {
        int i,k;
        sp.resize(n,vi (bit,0));
        rrep(i,n)
        {
            sp[i][0]=lcp[i];
            for(k=1;i+raise(k)<=n;k++)
                sp[i][k]=min(sp[i][k-1],sp[i+raise(k-1)][k-1]);
        }
        return ;
    }
    int lowerbound(string &temp)    // lowerbound index of some string
    {
        int m,l=0,r=n;
        while(l<r)
        {
            m=(l+r)/2;
            if(str.substr(v[m],min(sz(temp),n-v[m]))<temp)
                l=m+1;
            else
                r=m;
        }
        return l;
    }
    int upperbound(string &temp)    // upperbound index of some string
    {
        int m,l=0,r=n;
        while(l<r)
        {
            m=(l+r)/2;
            if(str.substr(v[m],min(sz(temp),n-v[m]))<=temp)
                l=m+1;
            else
                r=m;
        }
        return l;
    }
    int query(int a,int b)          // return min in [a,b] in lcp array or length of suffix if(b==a-1);
    {
        if(b==a-1)
            return n-v[a];
        int y,x=b-a+1;
        y=baselog2(x),x-=raise(y);
        return min(sp[a][y],sp[a+x][y]);
    }
    int common_prefix(int a,int b)  // lcp of two suffix start from a and b(a<n && b<n)
    {
        a=pos[a],b=pos[b];
        if(a>b)
            swap(a,b);
        return query(a,b-1);
    }
    int first_occurence(int k,int m)// first occurrence of suffix start from k of length m
    {
        int i,p=pos[k];
        rrep(i,bit)
            if(p-raise(i)>=0 && sp[p-raise(i)][i]>=m)p-=raise(i);
        return p;
    }
    int last_occurence(int k,int m) // last  occurrence of suffix start from k of length m
    {
        int i,p=pos[k];
        rrep(i,bit)
            if(p+raise(i)<=n && sp[p][i]>=m)p+=raise(i);
        return p;
    }
};
struct wavelet_tree
{
    vvi cnt;
    int s;
    typedef vector<int>::iterator itr;
    // sigma = size of alphabet, convert element into range [0,sigma-1]
    // sigma is one more than max_element of array
    // time complexity O(sigma*log2(sigma))
    void initialize(vi &v,int sigma)
    {
        cnt.resize(2*sigma);
        s=sigma;
        build(v.begin(),v.end(),0,s-1,1);
    }
    void build(itr b,itr e,int l,int h,int p)
    {
        if(l==h)
            return ;
        int m=middle();
        cnt[p].reserve(e-b+1);
        cnt[p].pb(0);
        for(itr cur=b;cur!=e;++cur)
            cnt[p].pb(cnt[p].back()+(*cur<=m));
        itr mid=stable_partition(b,e,[=](int i){return i<=m;});
        build(b,mid,l,m,lchild(p));
        build(mid,e,m+1,h,rchild(p));
    }
    int orderofkey(int a,int b,int k) // count number of element<=k in [a,b) 0-indexing
    {
        int l=0,h=s-1,p=1;
        int ans=0,m;
        int ra,rb;
        while(l<h)
        {
            m=middle();
            ra=cnt[p][a],rb=cnt[p][b];
            if(k<=m)
                a=ra,b=rb,h=m,p=lchild(p);
            else
                ans+=(rb-ra),a-=ra,b-=rb,l=m+1,p=rchild(p);
        }
        return ans+(b-a);
    }
};
struct distinct
{
    wavelet_tree ar;
    // element of array must be in range [0,n] where n is size of array
    distinct(vi &v)
    {
        int i,a,n=sz(v);
        vi last(n+1,-1);
        vi pos_next(n,n);
        rep(i,n)
        {
            a=v[i];
            if(last[a]>=0)
                pos_next[last[a]]=i;
            last[a]=i;
        }
        ar.initialize(pos_next,n+1);
    }
    int query(int a,int b) // number of distinct element in [a,b] 0-indexing
    {
        return b-a+1-ar.orderofkey(a,b+1,b);
    }
};
int num[N],aage[N];
void solve()
{
    int n,i,j,k;
    in2(n,k);
    vector<string> word(n);
    string str;
    rep(i,n)
        llin(word[i]),word[i]+='0',str+=word[i];
    int len=sz(str);
    int x=0,last=-1;
    rep(i,len)
    {
        num[i]=x;
        aage[i]=sz(word[x])-(i-last);
        if(str[i]=='0')
            x++,last=i;
    }
    suffix_array sa;
    sa.build(str);
    vi ar(sa.n);
    rep(i,sa.n)
        ar[i]=num[sa.v[i]];
    distinct number(ar);
    vector<ll> ans(n,0);
    int l,h,m,p,q;
    rep(i,len)
    {
        if(str[i]=='0')
            continue;
        l=0,h=aage[i];
        while(l<h)
        {
            m=(l+h+1)/2;
            p=sa.first_occurence(i,m);
            q=sa.last_occurence(i,m);
            if(number.query(p,q)>=k)
                l=m;
            else
                h=m-1;
        }
        ans[num[i]]+=l;
    }
    rep(i,n)
        llpr(ans[i]);
    lin;
}
int main()
{
    int t=1;
    //in(t);
    while(t--)
        solve();
}


#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define in4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define inp(p) in2(p.F,p.S)
#define llin(a) cin >> a
#define llin2(a,b) cin >> a >> b
#define llin3(a,b,c) cin >> a >> b >> c
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twodread(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define prp(p) pr2(p.F,p.S)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llpr2(a,b) cout << a << " " << b << "\n"
#define llout(a) cout << a << "\n"
#define pinttwod(mat,i,j,n,m) rep(i,n){rep(j,m)pr(mat[i][j]);   lin;}
#define plltwod(mat,i,j,n,m)  rep(i,n){rep(j,m)llpr(mat[i][j]); lin;}
#define byes printf("YES\n")
#define bno printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
#define test(q) cout << "Case #" << q << ": "
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define fone(i,n) for(i=1;i<=n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) (int)x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
#define middle() ((l+h)/2)
#define lchild(p) 2*p
#define rchild(p) 2*p+1
#define lseg l,m,2*p
#define rseg m+1,h,2*p+1
#define bhardo(mat,i,j,n,m,t) rep(i,n){rep(j,m)mat[i][j]=t;}
#define baselog2(n) __lg(n)
#define numberofbit(n) (32-__builtin_clz(n))
#define numberofbitll(n) (64-__builtin_clzll(n))
#define onbitcount(x)  __builtin_popcount(x)
#define onbitcountll(x)  __builtin_popcountll(x)
#define biton(mask,i)  ((mask>>i)&1)
#define bitoff(mask,i) (!((mask>>i)&1))
#define toggle(mask,i) (mask^=(1<<(i)))
#define raise(i) (1<<(i))
#define mul(p,q) ((ll)(p)*(ll)(q))
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define lii pair<ll,ll>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e18;
const int M = (1e9)+7;
//const int M= 998244353;
const int N = (2e5)+3;  // check the limit, man
/**
 Have you worked on Simplification of Idea?
 Ok! let's code, check whether it is correct or not?
*/
struct suffix_array
{
    vi v;           // store suffix array
    vi pos;         // store position of suffix from i in suffix array
    vi lcp;         // lcp array of size n with last value 0
    vvi sp;         // sparse table of lcp array of size n
    string str;     // string after adding last char
    int n;          // size of string after adding last char
    int bit;        // numberofbit(n)
    void build(string &cur)         // don't need to add last char manually
    {
        int ch=31;
        cur+=ch;
        str=cur;
        n=sz(str);
        bit=numberofbit(n);
        int i,j,a,c,k;
        vi order(n),nxt(n),temp(n),cnt(n);
        vector<pair<ii,int> > ar(n);
        rep(i,n)ar[i]={{str[i]-str[n-1],0},i};
        sort(all(ar));
        for(k=1;k<2*n;k*=2)
        {
            i=0,j=0,c=0;
            while(i<n)
            {
                while(j<n && ar[i].F==ar[j].F)order[ar[j].S]=c,j++;
                i=j,c++;
            }
            if(c==n)
                break;
            a=(k<n?k:k-n);
            rep(i,n)
            {
                nxt[i]=a++;
                if(a>=n)a-=n;
            }
            rep(i,c)cnt[i]=0;
            rep(i,n)++cnt[order[i]];
            lp(i,1,c)cnt[i]+=cnt[i-1];
            rrep(i,n)a=nxt[ar[i].S],temp[--cnt[order[a]]]=ar[i].S;
            rep(i,n)a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
            rep(i,c)cnt[i]=0;
            rep(i,n)++cnt[order[i]];
            lp(i,1,c)cnt[i]+=cnt[i-1];
            rrep(i,n)a=ar[i].S,temp[--cnt[order[a]]]=ar[i].S;
            rep(i,n)a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
        }
        v.resize(n);
        pos.resize(n);
        rep(i,n)
            v[i]=ar[i].S,pos[v[i]]=i;
        return lcp_construction();
    }
    void lcp_construction()
    {
        lcp.resize(n,0);
        int i,j,k=0;
        rep(i,n)
        {
            if(pos[i]==n-1)
            {
                k=0;
                continue;
            }
            j=v[pos[i]+1];
            while(i+k<n && j+k<n && str[i+k]==str[j+k])
                k++;
            lcp[pos[i]]=k;
            if(k)
                k--;
        }
        return build_sparsetable();
    }
    void build_sparsetable()
    {
        int i,k;
        sp.resize(n);
        rrep(i,n)
        {
            sp[i].resize(bit);
            sp[i][0]=lcp[i];
            for(k=1;i+raise(k)<=n;k++)
                sp[i][k]=min(sp[i][k-1],sp[i+raise(k-1)][k-1]);
        }
        return ;
    }
    int lowerbound(string &temp)    // lowerbound index of some string
    {
        int m,l=0,r=n;
        while(l<r)
        {
            m=(l+r)/2;
            if(str.substr(v[m],min(sz(temp),n-v[m]))<temp)
                l=m+1;
            else
                r=m;
        }
        return l;
    }
    int upperbound(string &temp)    // upperbound index of some string
    {
        int m,l=0,r=n;
        while(l<r)
        {
            m=(l+r)/2;
            if(str.substr(v[m],min(sz(temp),n-v[m]))<=temp)
                l=m+1;
            else
                r=m;
        }
        return l;
    }
    int query(int a,int b)          // return min in [a,b] in lcp array or length of suffix if(b==a-1);
    {
        if(b==a-1)
            return n-v[a];
        int y,x=b-a+1;
        y=baselog2(x),x-=raise(y);
        return min(sp[a][y],sp[a+x][y]);
    }
    int common_prefix(int a,int b)  // lcp of two suffix start from a and b(a<n && b<n)
    {
        a=pos[a],b=pos[b];
        if(a>b)
            swap(a,b);
        return query(a,b-1);
    }
    int first_occurence(int k,int m)// first occurrence of suffix start from k of length m
    {
        int i,p=pos[k];
        rrep(i,bit)
            if(p-raise(i)>=0 && sp[p-raise(i)][i]>=m)p-=raise(i);
        return p;
    }
    int last_occurence(int k,int m) // last  occurrence of suffix start from k of length m
    {
        int i,p=pos[k];
        rrep(i,bit)
            if(p+raise(i)<=n && sp[p][i]>=m)p+=raise(i);
        return p;
    }
};
struct wavelet_tree
{
    vvi cnt;
    int s;
    typedef vector<int>::iterator itr;
    // sigma = size of alphabet, convert element into range [0,sigma-1]
    // sigma is one more than max_element of array
    // time complexity O(sigma*log2(sigma))
    void initialize(vi &v,int sigma)
    {
        cnt.resize(2*sigma);
        s=sigma;
        build(v.begin(),v.end(),0,s-1,1);
    }
    void build(itr b,itr e,int l,int h,int p)
    {
        if(l==h)
            return ;
        int m=middle();
        cnt[p].reserve(e-b+1);
        cnt[p].pb(0);
        for(itr cur=b;cur!=e;++cur)
            cnt[p].pb(cnt[p].back()+(*cur<=m));
        itr mid=stable_partition(b,e,[=](int i){return i<=m;});
        build(b,mid,l,m,lchild(p));
        build(mid,e,m+1,h,rchild(p));
    }
    int orderofkey(int a,int b,int k) // count number of element<=k in [a,b) 0-indexing
    {
        int l=0,h=s-1,p=1;
        int ans=0,m;
        int ra,rb;
        while(l<h)
        {
            m=middle();
            ra=cnt[p][a],rb=cnt[p][b];
            if(k<=m)
                a=ra,b=rb,h=m,p=lchild(p);
            else
                ans+=(rb-ra),a-=ra,b-=rb,l=m+1,p=rchild(p);
        }
        return ans+(b-a);
    }
};
struct distinct
{
    wavelet_tree ar;
    // element of array must be in range [0,n] where n is size of array
    distinct(vi &v)
    {
        int i,a,n=sz(v);
        vi last(n+1,-1);
        vi pos_next(n,n);
        rep(i,n)
        {
            a=v[i];
            if(last[a]>=0)
                pos_next[last[a]]=i;
            last[a]=i;
        }
        ar.initialize(pos_next,n+1);
    }
    int query(int a,int b) // number of distinct element in [a,b] 0-indexing
    {
        return b-a+1-ar.orderofkey(a,b+1,b);
    }
};
int num[N],aage[N];
void solve()
{
    int n,i,j,k;
    in2(n,k);
    vector<string> word(n);
    string str;
    rep(i,n)
        llin(word[i]),word[i]+='0',str+=word[i];
    int len=sz(str);
    int x=0,last=-1;
    rep(i,len)
    {
        num[i]=x;
        aage[i]=sz(word[x])-(i-last);
        if(str[i]=='0')
            x++,last=i;
    }
    suffix_array sa;
    sa.build(str);
    vi ar(sa.n);
    rep(i,sa.n)
        ar[i]=num[sa.v[i]];
    distinct number(ar);
    vector<ll> ans(n,0);
    int l,h,m,p,q;
    rep(i,len)
    {
        if(str[i]=='0')
            continue;
        l=0,h=aage[i];
        while(l<h)
        {
            m=(l+h+1)/2;
            p=sa.first_occurence(i,m);
            q=sa.last_occurence(i,m);
            if(number.query(p,q)>=k)
                l=m;
            else
                h=m-1;
        }
        ans[num[i]]+=l;
    }
    rep(i,n)
        llpr(ans[i]);
    lin;
}
int main()
{
    int t=1;
    //in(t);
    while(t--)
        solve();
}


#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define in4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define inp(p) in2(p.F,p.S)
#define llin(a) cin >> a
#define llin2(a,b) cin >> a >> b
#define llin3(a,b,c) cin >> a >> b >> c
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twodread(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define prp(p) pr2(p.F,p.S)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llpr2(a,b) cout << a << " " << b << " "
#define llout(a) cout << a << "\n"
#define pinttwod(mat,i,j,n,m) rep(i,n){rep(j,m)pr(mat[i][j]);   lin;}
#define plltwod(mat,i,j,n,m)  rep(i,n){rep(j,m)llpr(mat[i][j]); lin;}
#define byes printf("YES\n")
#define bno printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
#define test(q) cout << "Case #" << q << ": "
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define fone(i,n) for(i=1;i<=n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) (int)x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
#define middle() ((l+h)/2)
#define lchild(p) 2*p
#define rchild(p) 2*p+1
#define lseg l,m,2*p
#define rseg m+1,h,2*p+1
#define bhardo(mat,i,j,n,m,t) rep(i,n){rep(j,m)mat[i][j]=t;}
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
#define biton(mask,i)  ((mask>>i)&1)
#define bitoff(mask,i) (!((mask>>i)&1))
#define toggle(mask,i) (mask^=(1<<(i)))
#define mul(p,q) ((ll)(p)*(ll)(q))
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define lii pair<ll,ll>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e18;
const int M = (1e9)+7;
//const int M= 998244353;
const int N = (2e5)+3;  // check the limit, man
const int K = 19;
/**
 Have you worked on Simplification of Idea?
 Ok! let's code, check whether it is correct or not?
*/
vi suffix_array(string &str)
{
    int i,j,a,c,k,n=sz(str);
    int cnt[n];
    vi order(n),nxt(n),temp(n);
    vector<pair<ii,int> > ar(n);
    rep(i,n)
        ar[i]={{str[i]-str[n-1],0},i};
    sort(all(ar));
    for(k=1;k<2*n;k*=2)
    {
        i=0,j=0,c=0;
        while(i<n)
        {
            while(j<n && ar[i].F==ar[j].F)
                order[ar[j].S]=c,j++;
            i=j,c++;
        }
        if(c==n)
            break;
        a=(k<n?k:k-n);
        rep(i,n)
        {
            nxt[i]=a++;
            if(a>=n)a-=n;
        }
        fill(cnt,cnt+c,0);
        rep(i,n)
            ++cnt[order[i]];
        lp(i,1,c)
            cnt[i]+=cnt[i-1];
        rrep(i,n)
            a=nxt[ar[i].S],temp[--cnt[order[a]]]=ar[i].S;
        rep(i,n)
            a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
        fill(cnt,cnt+c,0);
        rep(i,n)
            ++cnt[order[i]];
        lp(i,1,c)
            cnt[i]+=cnt[i-1];
        rrep(i,n)
            a=ar[i].S,temp[--cnt[order[a]]]=ar[i].S;
        rep(i,n)
            a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
    }
    vi v(n);
    rep(i,n)
        v[i]=ar[i].S;
    return v;
}
vi lcp_construction(string &str,vi &v)
{
    int n=sz(str);
    int i,j;
    vi pos(n,0);
    rep(i,n)
        pos[v[i]]=i;
    vi lcp(n-1,0);
    int k=0;
    rep(i,n)
    {
        if(pos[i]==n-1)
        {
            k=0;
            continue;
        }
        j=v[pos[i]+1];
        while(i+k<n && j+k<n && str[i+k]==str[j+k])
            k++;
        lcp[pos[i]]=k;
        if(k)
            k--;
    }
    return lcp;
}
struct wavelet_tree
{
    vvi cnt;
    int s;
    typedef vector<int>::iterator itr;
    // sigma = size of alphabet, convert element into range [0,sigma-1]
    // sigma is one more than max_element of array
    // time complexity O(sigma*log2(sigma))
    void initialize(vi &v,int sigma)
    {
        cnt.resize(2*sigma);
        s=sigma;
        build(v.begin(),v.end(),0,s-1,1);
    }
    void build(itr b,itr e,int l,int h,int p)
    {
        if(l==h)
            return ;
        int m=middle();
        cnt[p].reserve(e-b+1);
        cnt[p].pb(0);
        for(itr cur=b;cur!=e;++cur)
            cnt[p].pb(cnt[p].back()+(*cur<=m));
        itr mid=stable_partition(b,e,[=](int i){return i<=m;});
        build(b,mid,l,m,lchild(p));
        build(mid,e,m+1,h,rchild(p));
    }
    int orderofkey(int a,int b,int k) // count number of element<=k in [a,b) 0-indexing
    {
        int l=0,h=s-1,p=1;
        int ans=0,m;
        int ra,rb;
        while(l<h)
        {
            m=middle();
            ra=cnt[p][a],rb=cnt[p][b];
            if(k<=m)
                a=ra,b=rb,h=m,p=lchild(p);
            else
                ans+=(rb-ra),a-=ra,b-=rb,l=m+1,p=rchild(p);
        }
        return ans+(b-a);
    }
};
struct distinct
{
    wavelet_tree ar;
    // element of array must be in range [0,n] where n is size of array
    distinct(vi &v)
    {
        int i,a,n=sz(v);
        vi last(n+1,-1);
        vi pos_next(n,n);
        rep(i,n)
        {
            a=v[i];
            if(last[a]>=0)
                pos_next[last[a]]=i;
            last[a]=i;
        }
        ar.initialize(pos_next,n+1);
    }
    int query(int a,int b) // number of distinct element in [a,b] 0-indexing
    {
        return b-a+1-ar.orderofkey(a,b+1,b);
    }
};
struct sparse
{
    int sp[N][K];
    int po[K],ar[2*N];
    sparse()
    {
        int i,k;
        ar[1]=0,k=1,po[0]=1;
        while(k<N)
        {
            for(i=k+1;i<2*k;i++)
                ar[i]=ar[k];
            ar[2*k]=1+ar[k],k*=2;
        }
        for(i=1;i<K;i++)
            po[i]=2*po[i-1];
    }
    int operation(int a,int b)
    {
        return min(a,b);
    }
    void build(vi &val)
    {
        int i,k,n=sz(val);
        rrep(i,n)
        {
            sp[i][0]=val[i];
            for(k=1;i+po[k]<=n;k++)
                sp[i][k]=operation(sp[i][k-1],sp[i+po[k-1]][k-1]);
        }
    }
    int query(int a,int b)
    {
        if(a>b)
            return 0;
        int y,x=b-a+1;
        y=ar[x],x-=po[y];
        return operation(sp[a][y],sp[a+x][y]);
    }
};
int num[N],aage[N];
void solve()
{
    int n,i,j,k;
    in2(n,k);
    vector<string> word(n);
    string str;
    rep(i,n)
        llin(word[i]),word[i]+='0',str+=word[i];
    if(k==1 || k>n)
    {
        if(k==1)
        {
            rep(i,n)
                j=sz(word[i]),llpr(mul(j,j-1)/2);
        }
        if(k>n)
            rep(i,n)pr(0);
        lin,exit(0);
    }
    int len=sz(str);
    str+='$';
    auto v = suffix_array(str);
    auto lcp = lcp_construction(str,v);
    lcp.pb(0);
    rep(i,n+1)
        v.erase(v.begin()),lcp.erase(lcp.begin());
    int x=0,last=-1;
    rep(i,len)
    {
        num[i]=x;
        aage[i]=sz(word[x])-(i-last);
        if(str[i]=='0')
            x++,last=i;
    }
    vi ar;
    for(auto a : v)
        ar.pb(num[a]);
    distinct number(ar);
    vector<ll> ans(n,0);
    sparse rmq;
    rmq.build(lcp);
    len-=n;
    int l,h,m,a,p;
    rep(i,len)
    {
        l=0,h=aage[v[i]];
        while(l<h)
        {
            m=(l+h+1)/2;
            x=i;
            rrep(j,K)
            {
                a=(1<<j);
                if(x-a>=0 && rmq.sp[x-a][j]>=m)
                    x-=a;
            }
            p=x;
            rrep(j,K)
            {
                a=(1<<j);
                if(x+a-1<len && rmq.sp[x][j]>=m)
                    x+=a;
            }
            if(number.query(p,x)>=k)
                l=m;
            else
                h=m-1;
        }
        ans[num[v[i]]]+=l;
    }
    rep(i,n)
        llpr(ans[i]);
    lin;
}
int main()
{
    int t=1;
    //in(t);
    while(t--)
        solve();
}


#include<bits/stdc++.h>
using namespace std;
#pragma GCC target ("sse4.2")
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define in4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define inp(p) in2(p.F,p.S)
#define llin(a) cin >> a
#define llin2(a,b) cin >> a >> b
#define llin3(a,b,c) cin >> a >> b >> c
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twodread(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define prp(p) pr2(p.F,p.S)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llpr2(a,b) cout << a << " " << b << "\n"
#define llout(a) cout << a << "\n"
#define pinttwod(mat,i,j,n,m) rep(i,n){rep(j,m)pr(mat[i][j]);   lin;}
#define plltwod(mat,i,j,n,m)  rep(i,n){rep(j,m)llpr(mat[i][j]); lin;}
#define byes printf("YES\n")
#define bno printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
#define test(q) cout << "Case #" << q << ": "
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define fone(i,n) for(i=1;i<=n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) (int)x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
#define middle() ((l+h)/2)
#define lchild(p) 2*p
#define rchild(p) 2*p+1
#define lseg l,m,2*p
#define rseg m+1,h,2*p+1
#define bhardo(mat,i,j,n,m,t) rep(i,n){rep(j,m)mat[i][j]=t;}
#define baselog2(n) __lg(n)
#define numberofbit(n) (32-__builtin_clz(n))
#define numberofbitll(n) (64-__builtin_clzll(n))
#define onbitcount(x)  __builtin_popcount(x)
#define onbitcountll(x)  __builtin_popcountll(x)
#define biton(mask,i)  ((mask>>i)&1)
#define bitoff(mask,i) (!((mask>>i)&1))
#define toggle(mask,i) (mask^=(1<<(i)))
#define raise(i) (1<<(i))
#define mul(p,q) ((ll)(p)*(ll)(q))
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define lii pair<ll,ll>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e18;
const int M = (1e9)+7;
//const int M= 998244353;
const int N = (2e5)+3;  // check the limit, man
/**
 Have you worked on Simplification of Idea?
 Ok! let's code, check whether it is correct or not?
*/
struct suffix_array
{
    vi v;           // store suffix array
    vi pos;         // store position of suffix from i in suffix array
    vi lcp;         // lcp array of size n with last value 0
    vvi sp;         // sparse table of lcp array of size n
    string str;     // string after adding last char
    int n;          // size of string after adding last char
    void build(string &cur)         // don't need to add last char manually
    {
        int ch=31;
        cur+=ch;
        str=cur;
        int i,j,a,c,k;
        n=sz(str);
        vi order(n),nxt(n),temp(n),cnt(n);
        vector<pair<ii,int> > ar(n);
        rep(i,n)ar[i]={{str[i]-str[n-1],0},i};
        sort(all(ar));
        for(k=1;k<2*n;k*=2)
        {
            i=0,j=0,c=0;
            while(i<n)
            {
                while(j<n && ar[i].F==ar[j].F)order[ar[j].S]=c,j++;
                i=j,c++;
            }
            if(c==n)
                break;
            a=(k<n?k:k-n);
            rep(i,n)
            {
                nxt[i]=a++;
                if(a>=n)a-=n;
            }
            rep(i,c)cnt[i]=0;
            rep(i,n)++cnt[order[i]];
            lp(i,1,c)cnt[i]+=cnt[i-1];
            rrep(i,n)a=nxt[ar[i].S],temp[--cnt[order[a]]]=ar[i].S;
            rep(i,n)a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
            rep(i,c)cnt[i]=0;
            rep(i,n)++cnt[order[i]];
            lp(i,1,c)cnt[i]+=cnt[i-1];
            rrep(i,n)a=ar[i].S,temp[--cnt[order[a]]]=ar[i].S;
            rep(i,n)a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
        }
        v.resize(n);
        pos.resize(n);
        rep(i,n)
            v[i]=ar[i].S,pos[v[i]]=i;
        return lcp_construction();
    }
    void lcp_construction()
    {
        lcp.resize(n,0);
        int i,j,k=0;
        rep(i,n)
        {
            if(pos[i]==n-1)
            {
                k=0;
                continue;
            }
            j=v[pos[i]+1];
            while(i+k<n && j+k<n && str[i+k]==str[j+k])
                k++;
            lcp[pos[i]]=k;
            if(k)
                k--;
        }
        return build_sparsetable();
    }
    void build_sparsetable()
    {
        int i,k;
        sp.resize(n,vi (numberofbit(n),0));
        rrep(i,n)
        {
            sp[i][0]=lcp[i];
            for(k=1;i+raise(k)<=n;k++)
                sp[i][k]=min(sp[i][k-1],sp[i+raise(k-1)][k-1]);
        }
        return ;
    }
    int lowerbound(string &temp)    // lowerbound index of some string
    {
        int m,l=0,r=n;
        while(l<r)
        {
            m=(l+r)/2;
            if(str.substr(v[m],min(sz(temp),n-v[m]))<temp)
                l=m+1;
            else
                r=m;
        }
        return l;
    }
    int upperbound(string &temp)    // upperbound index of some string
    {
        int m,l=0,r=n;
        while(l<r)
        {
            m=(l+r)/2;
            if(str.substr(v[m],min(sz(temp),n-v[m]))<=temp)
                l=m+1;
            else
                r=m;
        }
        return l;
    }
    int query(int a,int b)          // return min in [a,b] in lcp array or length of suffix if(b==a-1);
    {
        if(b==a-1)
            return n-v[a];
        int y,x=b-a+1;
        y=baselog2(x),x-=raise(y);
        return min(sp[a][y],sp[a+x][y]);
    }
    int common_prefix(int a,int b)  // lcp of two suffix start from a and b(a<n && b<n)
    {
        a=pos[a],b=pos[b];
        if(a>b)
            swap(a,b);
        return query(a,b-1);
    }
    int first_occurence(int k,int m)// first occurrence of suffix start from k of length m
    {
        int i,p=pos[k];
        rrep(i,numberofbit(n))
            if(p-raise(i)>=0 && sp[p-raise(i)][i]>=m)p-=raise(i);
        return p;
    }
    int last_occurence(int k,int m) // last  occurrence of suffix start from k of length m
    {
        int i,p=pos[k];
        rrep(i,numberofbit(n))
            if(p+raise(i)<=n && sp[p][i]>=m)p+=raise(i);
        return p;
    }
};
struct wavelet_tree
{
    vvi cnt;
    int s;
    typedef vector<int>::iterator itr;
    // sigma = size of alphabet, convert element into range [0,sigma-1]
    // sigma is one more than max_element of array
    // time complexity O(sigma*log2(sigma))
    void initialize(vi &v,int sigma)
    {
        cnt.resize(2*sigma);
        s=sigma;
        build(v.begin(),v.end(),0,s-1,1);
    }
    void build(itr b,itr e,int l,int h,int p)
    {
        if(l==h)
            return ;
        int m=middle();
        cnt[p].reserve(e-b+1);
        cnt[p].pb(0);
        for(itr cur=b;cur!=e;++cur)
            cnt[p].pb(cnt[p].back()+(*cur<=m));
        itr mid=stable_partition(b,e,[=](int i){return i<=m;});
        build(b,mid,l,m,lchild(p));
        build(mid,e,m+1,h,rchild(p));
    }
    int orderofkey(int a,int b,int k) // count number of element<=k in [a,b) 0-indexing
    {
        int l=0,h=s-1,p=1;
        int ans=0,m;
        int ra,rb;
        while(l<h)
        {
            m=middle();
            ra=cnt[p][a],rb=cnt[p][b];
            if(k<=m)
                a=ra,b=rb,h=m,p=lchild(p);
            else
                ans+=(rb-ra),a-=ra,b-=rb,l=m+1,p=rchild(p);
        }
        return ans+(b-a);
    }
};
struct distinct
{
    wavelet_tree ar;
    // element of array must be in range [0,n] where n is size of array
    distinct(vi &v)
    {
        int i,a,n=sz(v);
        vi last(n+1,-1);
        vi pos_next(n,n);
        rep(i,n)
        {
            a=v[i];
            if(last[a]>=0)
                pos_next[last[a]]=i;
            last[a]=i;
        }
        ar.initialize(pos_next,n+1);
    }
    int query(int a,int b) // number of distinct element in [a,b] 0-indexing
    {
        return b-a+1-ar.orderofkey(a,b+1,b);
    }
};
int num[N],aage[N];
void solve()
{
    int n,i,j,k;
    in2(n,k);
    vector<string> word(n);
    string str;
    rep(i,n)
        llin(word[i]),word[i]+='0',str+=word[i];
    int len=sz(str);
    suffix_array sa;
    sa.build(str);
    auto v = sa.v;
    reverse(all(v));
    v.resize(len-n);
    reverse(all(v));
    int x=0,last=-1;
    rep(i,len)
    {
        num[i]=x;
        aage[i]=sz(word[x])-(i-last);
        if(str[i]=='0')
            x++,last=i;
    }
    vi ar;
    for(auto a : v)
        ar.pb(num[a]);
    distinct number(ar);
    vector<ll> ans(n,0);
    int l,h,m,p,q;
    rep(i,len)
    {
        if(str[i]=='0')
            continue;
        l=0,h=aage[i];
        while(l<h)
        {
            m=(l+h+1)/2;
            p=sa.first_occurence(i,m)-n-1;
            q=sa.last_occurence(i,m)-n-1;
            if(number.query(p,q)>=k)
                l=m;
            else
                h=m-1;
        }
        ans[num[i]]+=l;
    }
    rep(i,n)
        llpr(ans[i]);
    lin;
}
int main()
{
    int t=1;
    //in(t);
    while(t--)
        solve();
}


#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define in4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define inp(p) in2(p.F,p.S)
#define llin(a) cin >> a
#define llin2(a,b) cin >> a >> b
#define llin3(a,b,c) cin >> a >> b >> c
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twodread(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define prp(p) pr2(p.F,p.S)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llpr2(a,b) cout << a << " " << b << " "
#define llout(a) cout << a << "\n"
#define pinttwod(mat,i,j,n,m) rep(i,n){rep(j,m)pr(mat[i][j]);   lin;}
#define plltwod(mat,i,j,n,m)  rep(i,n){rep(j,m)llpr(mat[i][j]); lin;}
#define byes printf("YES\n")
#define bno printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
#define test(q) cout << "Case #" << q << ": "
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define fone(i,n) for(i=1;i<=n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) (int)x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
#define middle() ((l+h)/2)
#define lchild(p) 2*p
#define rchild(p) 2*p+1
#define lseg l,m,2*p
#define rseg m+1,h,2*p+1
#define bhardo(mat,i,j,n,m,t) rep(i,n){rep(j,m)mat[i][j]=t;}
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
#define biton(mask,i)  ((mask>>i)&1)
#define bitoff(mask,i) (!((mask>>i)&1))
#define toggle(mask,i) (mask^=(1<<(i)))
#define mul(p,q) ((ll)(p)*(ll)(q))
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define lii pair<ll,ll>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e18;
const int M = (1e9)+7;
//const int M= 998244353;
const int N = (2e5)+3;  // check the limit, man
const int K = 19;
/**
 Have you worked on Simplification of Idea?
 Ok! let's code, check whether it is correct or not?
*/
vi suffix_array(string &str)
{
    int i,j,a,c,k,n=sz(str);
    int cnt[n];
    vi order(n),nxt(n),temp(n);
    vector<pair<ii,int> > ar(n);
    rep(i,n)
        ar[i]={{str[i]-str[n-1],0},i};
    sort(all(ar));
    for(k=1;k<2*n;k*=2)
    {
        i=0,j=0,c=0;
        while(i<n)
        {
            while(j<n && ar[i].F==ar[j].F)
                order[ar[j].S]=c,j++;
            i=j,c++;
        }
        if(c==n)
            break;
        a=(k<n?k:k-n);
        rep(i,n)
        {
            nxt[i]=a++;
            if(a>=n)a-=n;
        }
        fill(cnt,cnt+c,0);
        rep(i,n)
            ++cnt[order[i]];
        lp(i,1,c)
            cnt[i]+=cnt[i-1];
        rrep(i,n)
            a=nxt[ar[i].S],temp[--cnt[order[a]]]=ar[i].S;
        rep(i,n)
            a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
        fill(cnt,cnt+c,0);
        rep(i,n)
            ++cnt[order[i]];
        lp(i,1,c)
            cnt[i]+=cnt[i-1];
        rrep(i,n)
            a=ar[i].S,temp[--cnt[order[a]]]=ar[i].S;
        rep(i,n)
            a=temp[i],ar[i]={{order[a],order[nxt[a]]},a};
    }
    vi v(n);
    rep(i,n)
        v[i]=ar[i].S;
    return v;
}
vi lcp_construction(string &str,vi &v)
{
    int n=sz(str);
    int i,j;
    vi pos(n,0);
    rep(i,n)
        pos[v[i]]=i;
    vi lcp(n-1,0);
    int k=0;
    rep(i,n)
    {
        if(pos[i]==n-1)
        {
            k=0;
            continue;
        }
        j=v[pos[i]+1];
        while(i+k<n && j+k<n && str[i+k]==str[j+k])
            k++;
        lcp[pos[i]]=k;
        if(k)
            k--;
    }
    return lcp;
}
struct wavelet_tree
{
    vvi cnt;
    int s;
    typedef vector<int>::iterator itr;
    // sigma = size of alphabet, convert element into range [0,sigma-1]
    // sigma is one more than max_element of array
    // time complexity O(sigma*log2(sigma))
    void initialize(vi &v,int sigma)
    {
        cnt.resize(2*sigma);
        s=sigma;
        build(v.begin(),v.end(),0,s-1,1);
    }
    void build(itr b,itr e,int l,int h,int p)
    {
        if(l==h)
            return ;
        int m=middle();
        cnt[p].reserve(e-b+1);
        cnt[p].pb(0);
        for(itr cur=b;cur!=e;++cur)
            cnt[p].pb(cnt[p].back()+(*cur<=m));
        itr mid=stable_partition(b,e,[=](int i){return i<=m;});
        build(b,mid,l,m,lchild(p));
        build(mid,e,m+1,h,rchild(p));
    }
    int orderofkey(int a,int b,int k) // count number of element<=k in [a,b) 0-indexing
    {
        int l=0,h=s-1,p=1;
        int ans=0,m;
        int ra,rb;
        while(l<h)
        {
            m=middle();
            ra=cnt[p][a],rb=cnt[p][b];
            if(k<=m)
                a=ra,b=rb,h=m,p=lchild(p);
            else
                ans+=(rb-ra),a-=ra,b-=rb,l=m+1,p=rchild(p);
        }
        return ans+(b-a);
    }
};
struct distinct
{
    wavelet_tree ar;
    // element of array must be in range [0,n] where n is size of array
    distinct(vi &v)
    {
        int i,a,n=sz(v);
        vi last(n+1,-1);
        vi pos_next(n,n);
        rep(i,n)
        {
            a=v[i];
            if(last[a]>=0)
                pos_next[last[a]]=i;
            last[a]=i;
        }
        ar.initialize(pos_next,n+1);
    }
    int query(int a,int b) // number of distinct element in [a,b] 0-indexing
    {
        return b-a+1-ar.orderofkey(a,b+1,b);
    }
};
struct sparse
{
    int sp[N][K];
    int po[K],ar[2*N];
    sparse()
    {
        int i,k;
        ar[1]=0,k=1,po[0]=1;
        while(k<N)
        {
            for(i=k+1;i<2*k;i++)
                ar[i]=ar[k];
            ar[2*k]=1+ar[k],k*=2;
        }
        for(i=1;i<K;i++)
            po[i]=2*po[i-1];
    }
    int operation(int a,int b)
    {
        return min(a,b);
    }
    void build(vi &val)
    {
        int i,k,n=sz(val);
        rrep(i,n)
        {
            sp[i][0]=val[i];
            for(k=1;i+po[k]<=n;k++)
                sp[i][k]=operation(sp[i][k-1],sp[i+po[k-1]][k-1]);
        }
    }
    int query(int a,int b)
    {
        if(a>b)
            return 0;
        int y,x=b-a+1;
        y=ar[x],x-=po[y];
        return operation(sp[a][y],sp[a+x][y]);
    }
};
int num[N],aage[N];
void solve()
{
    int n,i,j,k;
    in2(n,k);
    vector<string> word(n);
    string str;
    rep(i,n)
        llin(word[i]),word[i]+='0',str+=word[i];
    if(k==1 || k>n)
    {
        if(k==1)
        {
            rep(i,n)
                j=sz(word[i]),llpr(mul(j,j-1)/2);
        }
        if(k>n)
            rep(i,n)pr(0);
        lin,exit(0);
    }
    int len=sz(str);
    str+='$';
    auto v = suffix_array(str);
    auto lcp = lcp_construction(str,v);
    lcp.pb(0);
    reverse(all(v));
    v.resize(len-n);
    reverse(all(v));
    reverse(all(lcp));
    lcp.resize(len-n);
    reverse(all(lcp));
    int x=0,last=-1;
    rep(i,len)
    {
        num[i]=x;
        aage[i]=sz(word[x])-(i-last);
        if(str[i]=='0')
            x++,last=i;
    }
    vi ar;
    for(auto a : v)
        ar.pb(num[a]);
    distinct number(ar);
    vector<ll> ans(n,0);
    sparse rmq;
    rmq.build(lcp);
    len-=n;
    int l,h,m,a,p;
    rep(i,len)
    {
        l=0,h=aage[v[i]];
        while(l<h)
        {
            m=(l+h+1)/2;
            x=i;
            rrep(j,K)
            {
                a=(1<<j);
                if(x-a>=0 && rmq.sp[x-a][j]>=m)
                    x-=a;
            }
            p=x;
            rrep(j,K)
            {
                a=(1<<j);
                if(x+a-1<len && rmq.sp[x][j]>=m)
                    x+=a;
            }
            if(number.query(p,x)>=k)
                l=m;
            else
                h=m-1;
        }
        ans[num[v[i]]]+=l;
    }
    rep(i,n)
        llpr(ans[i]);
    lin;
}
int main()
{
    int t=1;
    //in(t);
    while(t--)
        solve();
}


#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

const int MaxN=100010;
const int INF=2000000010;

int n,v;
pair<int,int> a[MaxN];

void init()
{
	cin>>n;
	for (int i=1;i<=n;++i)
		scanf("%d%d",&a[i].first,&a[i].second);
	cin>>v;
	for (int i=1;i<=n;++i)
	{
		int x=a[i].first,t=a[i].second;
		a[i].first=v*t-x;
		a[i].second=v*t+x;
	}
}

int F[MaxN];

int solve_1()
{
	a[++n]=make_pair(0,0);
	sort(a+1,a+n+1);
	int ans=0;
	int flag=0;
	for (int i=1;i<=n;++i)
	{
		if (a[i].first==0&&a[i].second==0)
		{
			flag=1;
			F[0]=0;
			continue;
		}
		if (!flag) continue;
		if (a[i].second<0) continue;
		if (F[ans]<=a[i].second)
			F[++ans]=a[i].second;
		else
			F[upper_bound(F,F+ans+1,a[i].second)-F]=a[i].second;
	}
	return ans;
}

int solve_2()
{
	sort(a+1,a+n+1);
	int ans=0;
	F[0]=-INF;
	for (int i=1;i<=n;++i)
	{
		if (F[ans]<=a[i].second)
			F[++ans]=a[i].second;
		else
			F[upper_bound(F,F+ans+1,a[i].second)-F]=a[i].second;
	}
	return ans;
}

void work()
{
	int ans2=solve_2();
	int ans1=solve_1();
	cout<<ans1<<" "<<ans2<<endl;
}

int main()
{
	init();
	work();
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

const int MaxN=100010;
const int INF=2000000010;

int n,v;
pair<int,int> a[MaxN];

void init()
{
	cin>>n;
	for (int i=1;i<=n;++i)
		scanf("%d%d",&a[i].first,&a[i].second);
	cin>>v;
	for (int i=1;i<=n;++i)
	{
		int x=a[i].first,t=a[i].second;
		a[i].first=v*t-x;
		a[i].second=v*t+x;
	}
}

int F[MaxN];

int solve_1()
{
	a[++n]=make_pair(0,0);
	int ans=0;
	int flag=0;
	for (int i=1;i<=n;++i)
	{
		if (a[i].first==0&&a[i].second==0)
		{
			flag=1;
			F[0]=0;
		}
		if (!flag) continue;
		if (F[ans]<=a[i].second)
			F[++ans]=a[i].second;
		else
			F[upper_bound(F,F+ans+1,a[i].second)-F]=a[i].second;
	}
	return ans;
}

int solve_2()
{
	sort(a+1,a+n+1);
	int ans=0;
	F[0]=-INF;
	for (int i=1;i<=n;++i)
	{
		if (F[ans]<=a[i].second)
			F[++ans]=a[i].second;
		else
			F[upper_bound(F,F+ans+1,a[i].second)-F]=a[i].second;
	}
	return ans;
}

void work()
{
	int ans2=solve_2();
	int ans1=solve_1();
	cout<<ans1<<" "<<ans2<<endl;
}

int main()
{
	init();
	work();
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
long long a,b,c,d,e,f[100005],g[100005],h[100005],i,j,top;
struct node
{
        long long x,y;
        friend bool operator < (const node &x,const node &y)
        {
                return x.x<y.x || (x.x==y.x && x.y<y.y);
        }
};
struct node G[100005];

long long low,high,mid;
long long an1,an2;

int main()
{
        scanf("%I64d",&a);
        for(i=1;i<=a;i++) scanf("%I64d%I64d",&g[i],&h[i]);
        scanf("%I64d",&b);
        for(i=1;i<=a;i++) {G[i].x=b*h[i]-g[i];G[i].y=b*h[i]+g[i];}
        sort(G+1,G+a+1);
        //for(i=1;i<=a;i++)
        //    printf("%I64d %I64d\n",G[i].x,G[i].y);
        for(i=1;i<=a;i++)
        {
                 if(top==0 || G[i].y>=f[top] ) {f[++top]=G[i].y;continue;}
                 low=1;high=top;e=0;
                 while(low<=high)
                 {
                            mid=(low+high)>>1;
                            if(G[i].y>=f[mid])
                            {
                                    if(mid>e) e=mid;
                                    low=mid+1;
                            }
                            else
                                high=mid-1;
                 }
                 f[e+1]=G[i].y;
        }
        an2=top;
        top=0;
        G[a+1].x=0;G[a+1].y=0;
        sort(G+1,G+a+1+1);
        i=1;
        while(G[i].x!=0 || G[i].y!=0) i++;
        i++;
        //for(i=1;i<=a+1;i++)
         //   printf("%I64d %I64d\n",G[i].x,G[i].y);
        for(;i<=a+1;i++)
        if(G[i].y>=0)
        {
                 if(top==0 || G[i].y>=f[top] ) {f[++top]=G[i].y;continue;}
                 low=1;high=top;e=0;
                 while(low<=high)
                 {
                            mid=(low+high)>>1;
                            if(G[i].y>=f[mid])
                            {
                                    if(mid>e) e=mid;
                                    low=mid+1;
                            }
                            else
                                high=mid-1;
                 }
                 f[e+1]=G[i].y;
        }
        an1=top;
        printf("%I64d %I64d\n",an1,an2);
        return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>

using namespace std;

typedef long long LL;
#define N 100005
LL a[N],b[N],r[N],p[N],t[N];
int c[N],sa[N],f[N],n,m,v;
bool cmp(int i,int j)
{
    return b[i]>b[j]||(b[i]==b[j]&&t[i]>t[j]);
}
int ask(int x)
{
    int s=0;
    for(;x;x-=x&(-x))
        s=max(s,c[x]);
    return s;
}
void updata(int x,int d)
{
    for(;x<=m;x+=x&(-x))
        c[x]=max(c[x],d);
}
void work()
{
    int a1=0,a2=0;
    for(int i=1;i<=n;i++)
		sa[i]=i;
    sort(sa+1,sa+1+n,cmp);
    for(int j=1;j<=n;j++)
    {
        int i=sa[j],k;
        k=lower_bound(r+1,r+1+m,a[i])-r;
        f[i]=ask(k)+1;
        updata(k,f[i]);
        a2=max(a2,f[i]);
    }
    for(int i=1;i<=n;i++)
		 if(t[i]*v>=abs(p[i]))
        	a1=max(a1,f[i]);
    printf("%d %d\n",a1,a2);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
		 scanf("%I64d%I64d",p+i,t+i);
    scanf("%d",&v);
    for(int i=1;i<=n;i++)
	{
        a[i]=p[i]-t[i]*v;
        b[i]=p[i]+t[i]*v;
        r[++m]=a[i];
    }
    sort(r+1,r+1+m);
    m=unique(r+1,r+1+m)-r-1;
    work();
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#define Max 100005
#define F first
#define S second
#define MP make_pair
#define LL long long int

using namespace std;

pair<LL, LL> arr[Max];
int dp[Max];

bool cmp(const pair<LL, LL> &a, const pair<LL, LL> &b)
{
	if(a.F == b.F)
		return a.S < b.S;
	return a.F < b.F;
}

int lis(int a, int b)
{
	int n, i;
	long long int t;

	n = 0;
	for(i=a;i<=b;i++)
	{
		t = arr[i].S;
		if(!n || dp[n-1] >= t)
			dp[n++] = t;
		else
			*(upper_bound(dp, dp+n, t)-1) = t;
	}
	return n;
}

int main()
{
	int n, v, ans1, ans2, i;
	long long int a, b;

	scanf("%d", &n);
	for(i=0;i<n;i++)
		scanf("%I64d %I64d", &arr[i].F, &arr[i].S);
	scanf("%d", &v);

	for(i=0;i<n;i++)
	{
		a = arr[i].F;
		b = arr[i].S;

		arr[i].F = v*b + a;
		arr[i].S = v*b - a;
	}
	sort(arr, arr+n, cmp);

	ans2 = lis(0, n);

	arr[n].F = arr[n].S = 0;
	n++;

	sort(arr, arr+n, cmp);
	for(i=0;i<n;i++)
		if(arr[i].F==0 && arr[i].S==0)
			break;

	//cout<<i<<" "<<n<<"\n";
	ans1 = lis(i, n) - 1;

	printf("%d %d\n", ans1, ans2);
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#define Max 100005
#define F first
#define S second
#define MP make_pair
#define LL long long int

using namespace std;

pair<LL, LL> arr[Max];
int dp[Max];

bool cmp(const pair<LL, LL> &a, const pair<LL, LL> &b)
{
	if(a.F == b.F)
		return a.S < b.S;
	return a.F < b.F;
}

int lis(int a, int b, int neg)
{
	int n, i;
	long long int t;

/*	cout<<a<<" "<<b<<"\n";
	for(i=a;i<=b;i++)
		printf("!%I64d %I64d\n", arr[i].F, arr[i].S);*/

	n = 0;
	for(i=a;i<=b;i++)
	{
		t = arr[i].S;

		if(neg && t < 0)
			continue;
/*		cout<<"$\n";
		for(int j=0;j<n;j++)
			cout<<dp[j]<<" ";
		cout<<"\n";*/

		if(!n || dp[n-1] <= t)
			dp[n++] = t;
		else
		{
			//cout<<"find: ";
			//cout<<upper_bound(dp, dp+n, t)-dp<<"\n";

			*(upper_bound(dp, dp+n, t)) = t;
		}
	}
	return n;
}

int main()
{
	int n, v, ans1, ans2, i;
	long long int a, b;

	scanf("%d", &n);
	for(i=0;i<n;i++)
		scanf("%I64d %I64d", &arr[i].F, &arr[i].S);
	scanf("%d", &v);

	for(i=0;i<n;i++)
	{
		a = arr[i].F;
		b = arr[i].S;

		arr[i].F = v*b + a;
		arr[i].S = v*b - a;
	}
	sort(arr, arr+n, cmp);

	ans2 = lis(0, n-1, 0);

	arr[n].F = arr[n].S = 0;
	n++;

	sort(arr, arr+n, cmp);
	for(i=0;i<n;i++)
		if(arr[i].F==0 && arr[i].S==0)
			break;

	//cout<<i<<" "<<n<<"\n";
	ans1 = lis(i, n-1, 1) - 1;

	printf("%d %d\n", ans1, ans2);
}


#include<iostream>
#include<algorithm>
#define Max 100005
#define F first
#define S second
#define MP make_pair
#define LL long long int

using namespace std;

pair<LL, LL> arr[Max];
int dp[Max];

bool cmp(const pair<LL, LL> &a, const pair<LL, LL> &b)
{
	if(a.F == b.F)
		return a.S < b.S;
	return a.F < b.F;
}

int lis(int a, int b)
{
	int n, i;
	long long int t;

	n = 0;
	for(i=a;i<=b;i++)
	{
		t = arr[i].S;
		if(!n || dp[n-1] >= t)
			dp[n++] = t;
		else
			*(upper_bound(dp, dp+n, t)-1) = t;
	}
	return n;
}

int main()
{
	int n, v, ans1, ans2, i;
	long long int a, b;

	scanf("%d", &n);
	for(i=0;i<n;i++)
		scanf("%I64d %I64d", &arr[i].F, &arr[i].S);
	scanf("%d", &v);

	for(i=0;i<n;i++)
	{
		a = arr[i].F;
		b = arr[i].S;

		arr[i].F = v*b + a;
		arr[i].S = v*b - a;
	}
	sort(arr, arr+n, cmp);

	ans2 = lis(0, n);

	arr[n].F = arr[n].S = 0;
	n++;

	sort(arr, arr+n, cmp);
	for(i=0;i<n;i++)
		if(arr[i].F==0 && arr[i].S==0)
			break;

	//cout<<i<<" "<<n<<"\n";
	ans1 = lis(i, n) - 1;

	printf("%d %d\n", ans1, ans2);
}


#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define MP make_pair
#define PB push_back
#define A first
#define B second

typedef long long LL;
typedef pair<LL, LL> PLL;

int main() {
	int n; scanf("%d", &n);

	vector<PLL> g;
	for (int i = 0; i < n; ++i) {
		int x, t; scanf("%d%d", &x, &t);
		g.PB(MP(x, t));
	}

	int v; scanf("%d", &v);
	for (int i = 0; i < n; ++i) g[i] = MP(g[i].A + g[i].B * v, g[i].A - g[i].B * v);
	g.PB(MP(0, 0)); sort(g.begin(), g.end());

	int ans1 = 0, ans2 = 0;
	vector<LL> f;
	for (int i = n; i >= 0 ; --i) {
		LL x = g[i].B;
		int pos = upper_bound(f.begin(), f.end(), x) - f.begin();

		if (pos == f.size()) f.PB(x);
		else f[pos] = x;

		if (g[i].A == g[i].B) ans1 = max(ans1, pos);
		else ans2 = max(ans2, pos + 1);
	}

	printf("%d %d\n", ans1, ans2);

	return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define MP make_pair
#define PB push_back
#define A first
#define B second

typedef long long LL;
typedef pair<LL, LL> PLL;

int main() {
	int n; scanf("%d", &n);

	vector<PLL> g;
	for (int i = 0; i < n; ++i) {
		int x, t; scanf("%d%d", &x, &t);
		g.PB(MP(x, t));
	}

	int v; scanf("%d", &v);
	for (int i = 0; i < n; ++i) g[i] = MP(g[i].A - g[i].B * v, g[i].A + g[i].B * v);
	g.PB(MP(0, 0)); sort(g.begin(), g.end());

	int ans1 = 0, ans2 = 0;
	vector<LL> f;
	for (int i = 0; i <= n ; ++i) {
		LL x = -g[i].B;
		int pos = upper_bound(f.begin(), f.end(), x) - f.begin();

		if (pos == f.size()) f.PB(x);
		else f[pos] = x;

		if (g[i].A == g[i].B) ans1 = max(ans1, pos);
		else ans2 = max(ans2, pos + 1);
	}

	printf("%d %d\n", ans1, ans2);

	return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define MP make_pair
#define PB push_back
#define A first
#define B second

typedef long long LL;
typedef pair<LL, LL> PLL;

int main() {
	int n; scanf("%d", &n);

	vector<PLL> g;
	for (int i = 0; i < n; ++i) {
		int x, t; scanf("%d%d", &x, &t);
		g.PB(MP(x, t));
	}

	int v; scanf("%d", &v);
	for (int i = 0; i < n; ++i) g[i] = MP(g[i].A + g[i].B * v, - g[i].A + g[i].B * v);
	g.PB(MP(0, 0)); sort(g.begin(), g.end());

	int ans1 = 0, ans2 = 0;
	vector<LL> f;
	for (int i = n; i >= 0 ; --i) {
		LL x = -g[i].B;
		int pos = upper_bound(f.begin(), f.end(), x) - f.begin();

		if (pos == f.size()) f.PB(x);
		else f[pos] = x;

		if (g[i].A == g[i].B) ans1 = max(ans1, pos);
		else ans2 = max(ans2, pos + 1);
	}

	printf("%d %d\n", ans1, ans2);

	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 200001,oo = ~0U >> 10;

struct point
{
    double x,y;
}P[maxn];

int n,m,ans,res;
int Su[maxn],pos[maxn],rank[maxn],F[maxn];

int lowbit(int x)
{
    return x & (-x);
}

int cmp(point a,point b)
{
    return a.x < b.x || (a.x == b.x && a.y < b.y);
}

int cmpy(int a,int b)
{
    return P[a].y < P[b].y;
}

int ask(int x)
{
    int sum = 0;
    for (; x; x -= lowbit(x))
        sum = max(sum,Su[x]);
    return sum;
}

void change(int x,int y)
{
    for (; x <= m; x += lowbit(x))
        Su[x] = max(Su[x],y);
}

int main()
{
    int i,j;
    double V;

    scanf("%d",&n);
    for (i = 1; i <= n; ++i)
        scanf("%lf%lf",&P[i].x,&P[i].y);
    scanf("%lf",&V);
    for (i = 1; i <= n; ++i)
        P[i].x /= V;

    for (i = 1; i <= n; ++i)
        P[i] = (point){P[i].x+P[i].y,P[i].y-P[i].x};
    sort(P+1,P+n+1,cmp);
    for (i = 1; i <= n; ++i) pos[i] = i;
    sort(pos+1,pos+n+1,cmpy);
    for (i = 1,j = 0; i <= n; ++i)
    {
        if (i == 1 || P[pos[i]].y != P[pos[i-1]].y) ++j;
        rank[pos[i]] = j;
    }
    m = j;
    memset(Su,0,sizeof(Su));
    for (i = 1; i <= n; ++i)
    {
        F[i] = ask(rank[i])+1;
        change(rank[i],F[i]);
    }
    for (i = 1; i <= n; ++i)
        ans = max(ans,F[i]);

    P[++n] = (point){0,0};
    sort(P+1,P+n+1,cmp);
    for (i = 1; i <= n; ++i) pos[i] = i;
    sort(pos+1,pos+n+1,cmpy);
    for (i = 1,j = 0; i <= n; ++i)
    {
        if (i == 1 || P[pos[i]].y != P[pos[i-1]].y) ++j;
        rank[pos[i]] = j;
    }
    m = j;
    memset(Su,0,sizeof(Su));
    for (i = 1; i <= n; ++i)
    {
        if (P[i].x == 0 && P[i].y == 0)
        {
            F[i] = oo;
            change(rank[i],F[i]);
        }
        else F[i] = ask(rank[i])+1;
        change(rank[i],F[i]);
    }
    for (i = 1; i <= n; ++i)
        res = max(res,F[i]);
    printf("%d %d",res-oo,ans);

    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 200001,oo = ~0U >> 10;

struct point
{
    double x,y;
}P[maxn];

int n,m,ans,res;
int Su[maxn],pos[maxn],rank[maxn],F[maxn];

int lowbit(int x)
{
    return x & (-x);
}

int cmp(point a,point b)
{
    return a.x < b.x || (a.x == b.x && a.y < b.y);
}

int cmpy(int a,int b)
{
    return P[a].y < P[b].y;
}

int ask(int x)
{
    int sum = 0;
    for (; x; x -= lowbit(x))
        sum = max(sum,Su[x]);
    return sum;
}

void change(int x,int y)
{
    for (; x <= m; x += lowbit(x))
        Su[x] = max(Su[x],y);
}

int main()
{
    int i,j;
    double V;

    scanf("%d",&n);
    for (i = 1; i <= n; ++i)
        scanf("%lf%lf",&P[i].x,&P[i].y);
    scanf("%lf",&V);
    for (i = 1; i <= n; ++i)
        P[i].x /= V;

    for (i = 1; i <= n; ++i)
        P[i] = (point){P[i].x+P[i].y,P[i].y-P[i].x};
    sort(P+1,P+n+1,cmp);
    for (i = 1; i <= n; ++i) pos[i] = i;
    sort(pos+1,pos+n+1,cmpy);
    for (i = 1,j = 0; i <= n; ++i)
    {
        if (i == 1 || P[pos[i]].y != P[pos[i-1]].y) ++j;
        rank[pos[i]] = j;
    }
    m = j;
    memset(Su,0,sizeof(Su));
    for (i = 1; i <= n; ++i)
    {
        F[i] = ask(rank[i])+1;
        change(rank[i],F[i]);
    }
    for (i = 1; i <= n; ++i)
        ans = max(ans,F[i]);

    P[++n] = (point){0,0};
    sort(P+1,P+n+1,cmp);
    for (i = 1; i <= n; ++i) pos[i] = i;
    sort(pos+1,pos+n+1,cmpy);
    for (i = 1,j = 0; i <= n; ++i)
    {
        if (i == 1 || P[pos[i]].y != P[pos[i-1]].y) ++j;
        rank[pos[i]] = j;
    }
    m = j;
    memset(Su,0,sizeof(Su));

    for (i = 1; i <= n; ++i)
    {
        if (P[i].x == 0 && P[i].y == 0)
        {
            F[i] = oo;
            change(rank[i],F[i]);
        }
        else F[i] = ask(rank[i])+1;
        change(rank[i],F[i]);
    }
    for (i = 1; i <= n; ++i)
        res = max(res,F[i]);

    if (n == 6)
    {
        for (i = 1; i <= n; ++i)
            printf("%lf %lf ",P[i].x,P[i].y);
        printf("\n");
        for (i = 1; i <= n; ++i)
            printf("%d ",pos[i]);
        printf("\n");
        for (i = 1; i <= n; ++i)
            printf("%d ",F[i]);
        printf("\n");
    }

    printf("%d %d",res-oo,ans);

    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 200001,oo = ~0U >> 10;

struct point
{
    double x,y;
}P[maxn];

int n,m,ans,res;
int Su[maxn],pos[maxn],rank[maxn],F[maxn];

int lowbit(int x)
{
    return x & (-x);
}

int cmp(point a,point b)
{
    return a.x < b.x || (a.x == b.x && a.y < b.y);
}

int cmpy(int a,int b)
{
    return P[a].y < P[b].y;
}

int ask(int x)
{
    int sum = 0;
    for (; x; x -= lowbit(x))
        sum = max(sum,Su[x]);
    return sum;
}

void change(int x,int y)
{
    for (; x <= m; x += lowbit(x))
        Su[x] = max(Su[x],y);
}

int main()
{
    int i,j;
    double V;
    freopen("76F.in","r",stdin);
    freopen("76F.out","w",stdout);

    scanf("%d",&n);
    for (i = 1; i <= n; ++i)
        scanf("%lf%lf",&P[i].x,&P[i].y);
    scanf("%lf",&V);
    for (i = 1; i <= n; ++i)
        P[i].x /= V;

    for (i = 1; i <= n; ++i)
        P[i] = (point){P[i].x+P[i].y,P[i].y-P[i].x};
    sort(P+1,P+n+1,cmp);
    for (i = 1; i <= n; ++i) pos[i] = i;
    sort(pos+1,pos+n+1,cmpy);
    for (i = 1,j = 0; i <= n; ++i)
    {
        if (i == 1 || P[pos[i]].y != P[pos[i-1]].y) ++j;
        rank[pos[i]] = j;
    }
    m = j;
    memset(Su,0,sizeof(Su));
    for (i = 1; i <= n; ++i)
    {
        F[i] = ask(rank[i])+1;
        change(rank[i],F[i]);
    }
    for (i = 1; i <= n; ++i)
        ans = max(ans,F[i]);

    P[++n] = (point){0,0};
    sort(P+1,P+n+1,cmp);
    for (i = 1; i <= n; ++i) pos[i] = i;
    sort(pos+1,pos+n+1,cmpy);
    for (i = 1,j = 0; i <= n; ++i)
    {
        if (i == 1 || P[pos[i]].y != P[pos[i-1]].y) ++j;
        rank[pos[i]] = j;
    }
    m = j;
    memset(Su,0,sizeof(Su));

    for (i = 1; i <= n; ++i)
    {
        if (P[i].x == 0 && P[i].y == 0)
        {
            F[i] = oo;
            change(rank[i],F[i]);
        }
        else F[i] = ask(rank[i])+1;
        change(rank[i],F[i]);
    }
    for (i = 1; i <= n; ++i)
        res = max(res,F[i]);

    if (n == 6)
    {
        for (i = 1; i <= n; ++i)
            printf("%lf %lf ",P[i].x,P[i].y);
        printf("\n");
        for (i = 1; i <= n; ++i)
            printf("%d ",pos[i]);
        printf("\n");
        for (i = 1; i <= n; ++i)
            printf("%d ",F[i]);
        printf("\n");
    }

    printf("%d %d",res-oo,ans);

    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 200001,oo = ~0U >> 10;

struct point
{
    double x,y;
}P[maxn];

int n,m,ans,res;
int Su[maxn],pos[maxn],rank[maxn],F[maxn];

int lowbit(int x)
{
    return x & (-x);
}

int cmp(point a,point b)
{
    return a.x < b.x || (a.x == b.x && a.y < b.y);
}

int cmpy(int a,int b)
{
    return P[a].y < P[b].y;
}

int ask(int x)
{
    int sum = 0;
    for (; x; x -= lowbit(x))
        sum = max(sum,Su[x]);
    return sum;
}

void change(int x,int y)
{
    for (; x <= m; x += lowbit(x))
        Su[x] = max(Su[x],y);
}

int main()
{
    int i,j;
    double V,x,y;

    scanf("%d",&n);
    for (i = 1; i <= n; ++i)
        scanf("%lf%lf",&P[i].x,&P[i].y);
    scanf("%lf",&V);
    for (i = 1; i <= n; ++i)
        P[i].x /= V;

    for (i = 1; i <= n; ++i)
    {
        x = P[i].x+P[i].y;
        y = P[i].y-P[i].x;
        P[i] = (point){x,y};
    }
    sort(P+1,P+n+1,cmp);
    for (i = 1; i <= n; ++i) pos[i] = i;
    sort(pos+1,pos+n+1,cmpy);
    for (i = 1,j = 0; i <= n; ++i)
    {
        if (i == 1 || P[pos[i]].y != P[pos[i-1]].y) ++j;
        rank[pos[i]] = j;
    }
    m = j;
    memset(Su,0,sizeof(Su));
    for (i = 1; i <= n; ++i)
    {
        F[i] = ask(rank[i])+1;
        change(rank[i],F[i]);
    }
    for (i = 1; i <= n; ++i)
        ans = max(ans,F[i]);

    P[++n] = (point){0,0};
    sort(P+1,P+n+1,cmp);
    for (i = 1; i <= n; ++i) pos[i] = i;
    sort(pos+1,pos+n+1,cmpy);
    for (i = 1,j = 0; i <= n; ++i)
    {
        if (i == 1 || P[pos[i]].y != P[pos[i-1]].y) ++j;
        rank[pos[i]] = j;
    }
    m = j;
    memset(Su,0,sizeof(Su));

    for (i = 1; i <= n; ++i)
    {
        if (P[i].x == 0 && P[i].y == 0)
        {
            F[i] = oo;
            change(rank[i],F[i]);
        }
        else F[i] = ask(rank[i])+1;
        change(rank[i],F[i]);
    }
    for (i = 1; i <= n; ++i)
        res = max(res,F[i]);
/*

    if (n == 6)
    {
        for (i = 1; i <= n; ++i)
            printf("%lf %lf ",P[i].x,P[i].y);
        printf("\n");
        for (i = 1; i <= n; ++i)
            printf("%d ",pos[i]);
        printf("\n");
        for (i = 1; i <= n; ++i)
            printf("%d ",F[i]);
        printf("\n");
    }
*/
    printf("%d %d",res-oo,ans);

    return 0;
}