#define LL long long
#include<bits/stdc++.h>
using namespace std;
const LL maxn=1000000+5;
const LL mod=1000000007;
struct SuffixArray
{
    char s[maxn];
    LL minlen,n,c[maxn],rank[maxn],pri[maxn],sa[maxn];
    void build_sa(LL m)
    {
        n=strlen(s);s[n++]=0;
        for(LL i=0;i<m;i++) c[i]=0;
        for(LL i=0;i<n;i++) c[rank[i]=s[i]]++;
        for(LL i=1;i<m;i++) c[i]+=c[i-1];
        for(LL i=n-1;i>=0;i--) sa[--c[rank[i]]]=i;
        for(LL k=1;k<=n;k<<=1)
        {
            LL p=0;
            for(LL i=n-k;i<n;i++) pri[p++]=i;
            for(LL i=0;i<n;i++) if(sa[i]>=k) pri[p++]=sa[i]-k;

            for(LL i=0;i<m;i++) c[i]=0;
            for(LL i=0;i<n;i++) c[rank[pri[i]]]++;
            for(LL i=1;i<m;i++) c[i]+=c[i-1];
            for(LL i=n-1;i>=0;i--) sa[--c[rank[pri[i]]]]=pri[i];

            swap(rank,pri);
            p=0;rank[sa[0]]=p++;
            for(LL i=1;i<n;i++) rank[sa[i]]=(pri[sa[i]]==pri[sa[i-1]])&&(sa[i]+k<n)&&(sa[i-1]+k<n)&&(pri[sa[i]+k]==pri[sa[i-1]+k])?p-1:p++;
            if(p==n) break;
            m=p;
        }
    }

    LL H[maxn];
    void buildH()
    {
        for(LL i=0;i<n;i++) rank[sa[i]]=i;
        for(LL i=0,ans=0;i<n;i++)
        {
            if(ans) ans--;
            if(rank[i]==0) {H[rank[i]]=0;continue;}
            LL j=sa[rank[i]-1];
            while(s[i+ans]==s[j+ans]) ans++;
            H[rank[i]]=ans;
        }
    }
    LL l[3],ans[maxn],fa[maxn],cnt[maxn][3],vis[maxn];
    vector<LL> p[maxn],used;
    inline LL findset(LL x) {return fa[x]==x?x:fa[x]=findset(fa[x]);}
    inline LL getX(LL x){return x<l[1]?0:(x<l[2]?1:2);}
    void solve()
    {
        LL now=0;
        for(LL i=0;i<n;i++) {fa[i]=i;p[H[i]].push_back(i);}
        for(LL L=n;L>=1;L--)
        {
            for(LL j=0;j<p[L].size();j++)
            {
                LL P=p[L][j];vis[P]=1;used.push_back(P);
                cnt[P][getX(sa[P])]++;
                if(P>0 && vis[P-1])
                {
                    LL front=findset(P-1);
                    cnt[front][getX(sa[front-1])]++;(now-=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod)%=mod;cnt[front][getX(sa[front-1])]--;
                    for(LL i=0;i<3;i++) (cnt[front][i]+=cnt[P][i])%=mod;
                    cnt[front][getX(sa[front-1])]++;(((now+=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod)%=mod)+=mod)%=mod;cnt[front][getX(sa[front-1])]--;
                    fa[P]=front;
                }
                if(P<n-1 && vis[P+1])// merge to back
                {
                    LL me=findset(P); // to sa[me-1]
                    cnt[P+1][getX(sa[P])]++;cnt[me][getX(sa[me-1])]++;
                    (now-=((cnt[P+1][0]*cnt[P+1][1]*cnt[P+1][2])%mod+(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%mod)%=mod;
                    cnt[P+1][getX(sa[P])]--;cnt[me][getX(sa[me-1])]--;
                    for(LL i=0;i<3;i++) (cnt[me][i]+=cnt[P+1][i])%=mod;
                    cnt[me][getX(sa[me-1])]++;
                    (((now+=(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%=mod)+=mod)%=mod;
                    cnt[me][getX(sa[me-1])]--;
                    fa[P+1]=me;
                }
            }
            ans[L]=now;
        }
        for(LL i=1;i<=minlen;i++) printf("%I64d%c",ans[i],i==minlen?'\n':' ');
    }
}SA;
char tmp[maxn];
int main()
{
    LL trash='W';SA.n=0;
    scanf("%s",SA.s);SA.l[0]=SA.n;SA.n=strlen(SA.s);SA.minlen=SA.n;
    for(LL i=1;i<=2;i++)
    {
        SA.s[SA.n++]=trash++;
        SA.l[i]=SA.n;
        scanf("%s",tmp);
        LL n=strlen(tmp);SA.minlen=min(SA.minlen,n);
        for(LL j=0;j<n;j++) SA.s[SA.n++]=tmp[j];
    }
    SA.build_sa('z'+5);SA.buildH();SA.solve();
}


#define LL long long
#include<bits/stdc++.h>
using namespace std;
const LL maxn=1000000+5;
const LL mod=1000000007;
struct SuffixArray
{
    char s[maxn];
    LL minlen,n,c[maxn],rank[maxn],pri[maxn],sa[maxn];
    void build_sa(LL m)
    {
        n=strlen(s);s[n++]=0;
        for(LL i=0;i<m;i++) c[i]=0;
        for(LL i=0;i<n;i++) c[rank[i]=s[i]]++;
        for(LL i=1;i<m;i++) c[i]+=c[i-1];
        for(LL i=n-1;i>=0;i--) sa[--c[rank[i]]]=i;
        for(LL k=1;k<=n;k<<=1)
        {
            LL p=0;
            for(LL i=n-k;i<n;i++) pri[p++]=i;
            for(LL i=0;i<n;i++) if(sa[i]>=k) pri[p++]=sa[i]-k;

            for(LL i=0;i<m;i++) c[i]=0;
            for(LL i=0;i<n;i++) c[rank[pri[i]]]++;
            for(LL i=1;i<m;i++) c[i]+=c[i-1];
            for(LL i=n-1;i>=0;i--) sa[--c[rank[pri[i]]]]=pri[i];

            swap(rank,pri);
            p=0;rank[sa[0]]=p++;
            for(LL i=1;i<n;i++) rank[sa[i]]=(pri[sa[i]]==pri[sa[i-1]])&&(sa[i]+k<n)&&(sa[i-1]+k<n)&&(pri[sa[i]+k]==pri[sa[i-1]+k])?p-1:p++;
            if(p==n) break;
            m=p;
        }
    }

    LL H[maxn];
    void buildH()
    {
        for(LL i=0;i<n;i++) rank[sa[i]]=i;
        for(LL i=0,ans=0;i<n;i++)
        {
            if(ans) ans--;
            if(rank[i]==0) {H[rank[i]]=0;continue;}
            LL j=sa[rank[i]-1];
            while(s[i+ans]==s[j+ans]) ans++;
            H[rank[i]]=ans;
        }
    }
    LL l[3],ans[maxn],fa[maxn],cnt[maxn][3],vis[maxn];
    vector<LL> p[maxn],used;
    inline LL findset(LL x) {return fa[x]==x?x:fa[x]=findset(fa[x]);}
    inline LL getX(LL x){return x<l[1]?0:(x<l[2]?1:2);}
    void solve()
    {
        LL now=0;
        for(LL i=0;i<n;i++) {fa[i]=i;p[H[i]].push_back(i);}
        for(LL L=n;L>=1;L--)
        {
            for(LL j=0;j<p[L].size();j++)
            {
                LL P=p[L][j];vis[P]=1;used.push_back(P);
                cnt[P][getX(sa[P])]++;
                if(P>0 && vis[P-1])
                {
                    LL front=findset(P-1);
                    cnt[front][getX(sa[front-1])]++;(now-=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod)%=mod;cnt[front][getX(sa[front-1])]--;
                    for(LL i=0;i<3;i++) (cnt[front][i]+=cnt[P][i])%=mod;
                    cnt[front][getX(sa[front-1])]++;(((now+=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod)%=mod)+=mod)%=mod;cnt[front][getX(sa[front-1])]--;
                    fa[P]=front;
                }
                if(P<n-1 && vis[P+1])// merge to back
                {
                    LL me=findset(P); // to sa[me-1]
                    cnt[P+1][getX(sa[P])]++;cnt[me][getX(sa[me-1])]++;(now-=((cnt[P+1][0]*cnt[P+1][1]*cnt[P+1][2])%mod+(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%mod)%=mod;cnt[P+1][getX(sa[P])]--;cnt[me][getX(sa[me-1])]--;
                    for(LL i=0;i<3;i++) (cnt[me][i]+=cnt[P+1][i])%=mod;
                    cnt[me][getX(sa[me-1])]++;(((now+=(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%=mod)+=mod)%=mod;cnt[me][getX(sa[me-1])]--;
                    fa[P+1]=me;
                }
            }
            ans[L]=now;
        }
        for(LL i=1;i<=minlen;i++) printf("%I64d%c",ans[i],i==minlen?'\n':' ');
    }
}SA;
char tmp[maxn];
int main()
{
    LL trash='W';SA.n=0;
    scanf("%s",SA.s);SA.l[0]=SA.n;SA.n=strlen(SA.s);SA.minlen=SA.n;
    for(LL i=1;i<=2;i++)
    {
        SA.s[SA.n++]=trash++;
        SA.l[i]=SA.n;
        scanf("%s",tmp);
        LL n=strlen(tmp);SA.minlen=min(SA.minlen,n);
        for(LL j=0;j<n;j++) SA.s[SA.n++]=tmp[j];
    }
    SA.build_sa('z'+5);SA.buildH();SA.solve();
}


#define LL long long
#include<bits/stdc++.h>
using namespace std;
const LL maxn=1000000+5;
const LL mod=1000000007;
struct SuffixArray
{
    char s[maxn];
    LL minlen,n,c[maxn],rank[maxn],pri[maxn],sa[maxn];
    void build_sa(LL m)
    {
        n=strlen(s);s[n++]=0;
        for(LL i=0;i<m;i++) c[i]=0;
        for(LL i=0;i<n;i++) c[rank[i]=s[i]]++;
        for(LL i=1;i<m;i++) c[i]+=c[i-1];
        for(LL i=n-1;i>=0;i--) sa[--c[rank[i]]]=i;
        for(LL k=1;k<=n;k<<=1)
        {
            LL p=0;
            for(LL i=n-k;i<n;i++) pri[p++]=i;
            for(LL i=0;i<n;i++) if(sa[i]>=k) pri[p++]=sa[i]-k;

            for(LL i=0;i<m;i++) c[i]=0;
            for(LL i=0;i<n;i++) c[rank[pri[i]]]++;
            for(LL i=1;i<m;i++) c[i]+=c[i-1];
            for(LL i=n-1;i>=0;i--) sa[--c[rank[pri[i]]]]=pri[i];

            swap(rank,pri);
            p=0;rank[sa[0]]=p++;
            for(LL i=1;i<n;i++) rank[sa[i]]=(pri[sa[i]]==pri[sa[i-1]])&&(sa[i]+k<n)&&(sa[i-1]+k<n)&&(pri[sa[i]+k]==pri[sa[i-1]+k])?p-1:p++;
            if(p==n) break;
            m=p;
        }
    }

    LL H[maxn];
    void buildH()
    {
        for(LL i=0;i<n;i++) rank[sa[i]]=i;
        for(LL i=0,ans=0;i<n;i++)
        {
            if(ans) ans--;
            if(rank[i]==0) {H[rank[i]]=0;continue;}
            LL j=sa[rank[i]-1];
            while(s[i+ans]==s[j+ans]) ans++;
            H[rank[i]]=ans;
        }
    }
    LL l[3],ans[maxn],fa[maxn],cnt[maxn][3],vis[maxn];
    vector<LL> p[maxn],used;
    inline LL findset(LL x) {return fa[x]==x?x:fa[x]=findset(fa[x]);}
    inline LL getX(LL x){return x<l[1]?0:(x<l[2]?1:2);}
    void solve()
    {
        LL now=0;
        for(LL i=0;i<n;i++) {fa[i]=i;p[H[i]].push_back(i);}
        for(LL L=n;L>=1;L--)
        {
            for(LL j=0;j<p[L].size();j++)
            {
                LL P=p[L][j];vis[P]=1;used.push_back(P);
                cnt[P][getX(sa[P])]++;
                if(P>0 && vis[P-1])// merge to front
                {
                    LL front=findset(P-1); // to sa[front-1]
                    cnt[front][getX(sa[front-1])]++;
                    now-=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod;
                    cnt[front][getX(sa[front-1])]--;
                    for(LL i=0;i<3;i++) (cnt[front][i]+=cnt[P][i])%=mod;
                    cnt[front][getX(sa[front-1])]++;
                    now+=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod;
                    cnt[front][getX(sa[front-1])]--;
                    fa[P]=front;
                }
                if(P<n-1 && vis[P+1])// merge to back
                {
                    LL me=findset(P); // to sa[me-1]
                    cnt[P+1][getX(sa[P])]++;cnt[me][getX(sa[me-1])]++;
                    now-=((cnt[P+1][0]*cnt[P+1][1]*cnt[P+1][2])%mod+(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%mod;
                    cnt[P+1][getX(sa[P])]--;cnt[me][getX(sa[me-1])]--;
                    for(LL i=0;i<3;i++) (cnt[me][i]+=cnt[P+1][i])%=mod;
                    cnt[me][getX(sa[me-1])]++;
                    now+=(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod;
                    cnt[me][getX(sa[me-1])]--;
                    fa[P+1]=me;
                }
            }
            ans[L]=now;
        }
        for(LL i=1;i<=minlen;i++) printf("%I64d%c",ans[i],i==minlen?'\n':' ');
    }
}SA;
char tmp[maxn];
int main()
{
    LL trash='W';SA.n=0;
    scanf("%s",SA.s);SA.l[0]=SA.n;SA.n=strlen(SA.s);SA.minlen=SA.n;
    for(LL i=1;i<=2;i++)
    {
        SA.s[SA.n++]=trash++;
        SA.l[i]=SA.n;
        scanf("%s",tmp);
        LL n=strlen(tmp);SA.minlen=min(SA.minlen,n);
        for(LL j=0;j<n;j++) SA.s[SA.n++]=tmp[j];
    }
    SA.build_sa('z'+5);SA.buildH();SA.solve();
}


#define LL long long
#include<bits/stdc++.h>
using namespace std;
const LL maxn=1000000+5;
const LL mod=1000000007;
struct SuffixArray
{
    char s[maxn];
    LL minlen,n,c[maxn],rank[maxn],pri[maxn],sa[maxn];
    void build_sa(LL m)
    {
        n=strlen(s);s[n++]=0;
        for(LL i=0;i<m;i++) c[i]=0;
        for(LL i=0;i<n;i++) c[rank[i]=s[i]]++;
        for(LL i=1;i<m;i++) c[i]+=c[i-1];
        for(LL i=n-1;i>=0;i--) sa[--c[rank[i]]]=i;
        for(LL k=1;k<=n;k<<=1)
        {
            LL p=0;
            for(LL i=n-k;i<n;i++) pri[p++]=i;
            for(LL i=0;i<n;i++) if(sa[i]>=k) pri[p++]=sa[i]-k;

            for(LL i=0;i<m;i++) c[i]=0;
            for(LL i=0;i<n;i++) c[rank[pri[i]]]++;
            for(LL i=1;i<m;i++) c[i]+=c[i-1];
            for(LL i=n-1;i>=0;i--) sa[--c[rank[pri[i]]]]=pri[i];

            swap(rank,pri);
            p=0;rank[sa[0]]=p++;
            for(LL i=1;i<n;i++) rank[sa[i]]=(pri[sa[i]]==pri[sa[i-1]])&&(sa[i]+k<n)&&(sa[i-1]+k<n)&&(pri[sa[i]+k]==pri[sa[i-1]+k])?p-1:p++;
            if(p==n) break;
            m=p;
        }
    }

    LL H[maxn];
    void buildH()
    {
        for(LL i=0;i<n;i++) rank[sa[i]]=i;
        for(LL i=0,ans=0;i<n;i++)
        {
            if(ans) ans--;
            if(rank[i]==0) {H[rank[i]]=0;continue;}
            LL j=sa[rank[i]-1];
            while(s[i+ans]==s[j+ans]) ans++;
            H[rank[i]]=ans;
        }
    }
    LL l[3],ans[maxn],fa[maxn],cnt[maxn][3],vis[maxn];
    vector<LL> p[maxn],used;
    inline LL findset(LL x) {return fa[x]==x?x:fa[x]=findset(fa[x]);}
    inline LL getX(LL x){return x<l[1]?0:(x<l[2]?1:2);}
    void solve()
    {
        LL now=0;
        for(LL i=0;i<n;i++) {fa[i]=i;p[H[i]].push_back(i);}
        for(LL L=n;L>=1;L--)
        {
            for(LL j=0;j<p[L].size();j++)
            {
                LL P=p[L][j];vis[P]=1;used.push_back(P);
                cnt[P][getX(sa[P])]++;
                if(P>0 && vis[P-1])// merge to front
                {
                    LL front=findset(P-1); // to sa[front-1]
                    cnt[front][getX(sa[front-1])]++;
                    (now-=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod)%=mod;
                    cnt[front][getX(sa[front-1])]--;
                    for(LL i=0;i<3;i++) (cnt[front][i]+=cnt[P][i])%=mod;
                    cnt[front][getX(sa[front-1])]++;
                    (((now+=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod)%=mod)+=mod)%=mod;
                    cnt[front][getX(sa[front-1])]--;
                    fa[P]=front;
                }
                if(P<n-1 && vis[P+1])// merge to back
                {
                    LL me=findset(P); // to sa[me-1]
                    cnt[P+1][getX(sa[P])]++;cnt[me][getX(sa[me-1])]++;
                    (now-=((cnt[P+1][0]*cnt[P+1][1]*cnt[P+1][2])%mod+(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%mod)%=mod;
                    cnt[P+1][getX(sa[P])]--;cnt[me][getX(sa[me-1])]--;
                    for(LL i=0;i<3;i++) (cnt[me][i]+=cnt[P+1][i])%=mod;
                    cnt[me][getX(sa[me-1])]++;
                    (((now+=(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%=mod)+=mod)%=mod;
                    cnt[me][getX(sa[me-1])]--;
                    fa[P+1]=me;
                }
            }
            ans[L]=now;
        }
        for(LL i=1;i<=minlen;i++) printf("%I64d%c",ans[i],i==minlen?'\n':' ');
    }
}SA;
char tmp[maxn];
int main()
{
    LL trash='W';SA.n=0;
    scanf("%s",SA.s);SA.l[0]=SA.n;SA.n=strlen(SA.s);SA.minlen=SA.n;
    for(LL i=1;i<=2;i++)
    {
        SA.s[SA.n++]=trash++;
        SA.l[i]=SA.n;
        scanf("%s",tmp);
        LL n=strlen(tmp);SA.minlen=min(SA.minlen,n);
        for(LL j=0;j<n;j++) SA.s[SA.n++]=tmp[j];
    }
    SA.build_sa('z'+5);SA.buildH();SA.solve();
}


#define LL long long
#include<bits/stdc++.h>
using namespace std;
const LL maxn=1000000+5;
const LL mod=1000000007;
struct SuffixArray
{
    char s[maxn];
    LL minlen,n,c[maxn],rank[maxn],pri[maxn],sa[maxn];
    void build_sa(LL m)
    {
        n=strlen(s);s[n++]=0;
        for(LL i=0;i<m;i++) c[i]=0;
        for(LL i=0;i<n;i++) c[rank[i]=s[i]]++;
        for(LL i=1;i<m;i++) c[i]+=c[i-1];
        for(LL i=n-1;i>=0;i--) sa[--c[rank[i]]]=i;
        for(LL k=1;k<=n;k<<=1)
        {
            LL p=0;
            for(LL i=n-k;i<n;i++) pri[p++]=i;
            for(LL i=0;i<n;i++) if(sa[i]>=k) pri[p++]=sa[i]-k;

            for(LL i=0;i<m;i++) c[i]=0;
            for(LL i=0;i<n;i++) c[rank[pri[i]]]++;
            for(LL i=1;i<m;i++) c[i]+=c[i-1];
            for(LL i=n-1;i>=0;i--) sa[--c[rank[pri[i]]]]=pri[i];

            swap(rank,pri);
            p=0;rank[sa[0]]=p++;
            for(LL i=1;i<n;i++) rank[sa[i]]=(pri[sa[i]]==pri[sa[i-1]])&&(sa[i]+k<n)&&(sa[i-1]+k<n)&&(pri[sa[i]+k]==pri[sa[i-1]+k])?p-1:p++;
            if(p==n) break;
            m=p;
        }
    }

    LL H[maxn];
    void buildH()
    {
        for(LL i=0;i<n;i++) rank[sa[i]]=i;
        for(LL i=0,ans=0;i<n;i++)
        {
            if(ans) ans--;
            if(rank[i]==0) {H[rank[i]]=0;continue;}
            LL j=sa[rank[i]-1];
            while(s[i+ans]==s[j+ans]) ans++;
            H[rank[i]]=ans;
        }
    }
    LL l[3],ans[maxn],fa[maxn],cnt[maxn][3],vis[maxn];
    vector<int> p[maxn];
    inline LL findset(LL x) {return fa[x]==x?x:fa[x]=findset(fa[x]);}
    inline LL getX(LL x){return x<l[1]?0:(x<l[2]?1:2);}
    void solve()
    {
        LL now=0;
        for(LL i=0;i<n;i++) {fa[i]=i;p[H[i]].push_back(i);}
        for(LL L=minlen;L>=1;L--)
        {
            for(LL j=0;j<p[L].size();j++)
            {
                LL P=p[L][j];vis[P]=1;
                cnt[P][getX(sa[P])]++;
                if(P>0 && vis[P-1])// merge to front
                {
                    LL front=findset(P-1); // to sa[front-1]
                    cnt[front][getX(sa[front-1])]++;
                    now-=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod;
                    cnt[front][getX(sa[front-1])]--;
                    for(LL i=0;i<3;i++) (cnt[front][i]+=cnt[P][i])%=mod;
                    cnt[front][getX(sa[front-1])]++;
                    now+=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod;
                    cnt[front][getX(sa[front-1])]--;
                    fa[P]=front;
                }
                if(P<n-1 && vis[P+1])// merge to back
                {
                    LL me=findset(P); // to sa[me-1]
                    cnt[P+1][getX(sa[P])]++;cnt[me][getX(sa[me-1])]++;
                    now-=((cnt[P+1][0]*cnt[P+1][1]*cnt[P+1][2])%mod+(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%mod;
                    cnt[P+1][getX(sa[P])]--;cnt[me][getX(sa[me-1])]--;
                    for(LL i=0;i<3;i++) (cnt[me][i]+=cnt[P+1][i])%=mod;
                    cnt[me][getX(sa[me-1])]++;
                    now+=(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod;
                    cnt[me][getX(sa[me-1])]--;
                    fa[P+1]=me;
                }
            }
            ans[L]=now;
        }
        for(LL i=1;i<=minlen;i++) printf("%I64d%c",ans[i],i==minlen?'\n':' ');
    }
    void debug()
    {
        printf("%s\n",s);
        for(LL i=0;i<n;i++) printf("sa[%I64d]:%s H[%I64d]:%I64d\n",i,s+sa[i],i,H[i]);
    }
}SA;
char tmp[maxn];
int main()
{
    LL trash='W';SA.n=0;
    scanf("%s",SA.s);SA.l[0]=SA.n;SA.n=strlen(SA.s);SA.minlen=SA.n;
    for(LL i=1;i<=2;i++)
    {
        SA.s[SA.n++]=trash++;
        SA.l[i]=SA.n;
        scanf("%s",tmp);
        LL n=strlen(tmp);SA.minlen=min(SA.minlen,n);
        for(LL j=0;j<n;j++) SA.s[SA.n++]=tmp[j];
    }
    SA.build_sa('z');SA.buildH();SA.solve();
}


#define LL long long
#include<bits/stdc++.h>
using namespace std;
const LL maxn=1000000+5;
const LL mod=1000000007;
struct SuffixArray
{
    char s[maxn];
    LL minlen,n,c[maxn],rank[maxn],pri[maxn],sa[maxn];
    void build_sa(LL m)
    {
        n=strlen(s);s[n++]=0;
        for(LL i=0;i<m;i++) c[i]=0;
        for(LL i=0;i<n;i++) c[rank[i]=s[i]]++;
        for(LL i=1;i<m;i++) c[i]+=c[i-1];
        for(LL i=n-1;i>=0;i--) sa[--c[rank[i]]]=i;
        for(LL k=1;k<=n;k<<=1)
        {
            LL p=0;
            for(LL i=n-k;i<n;i++) pri[p++]=i;
            for(LL i=0;i<n;i++) if(sa[i]>=k) pri[p++]=sa[i]-k;

            for(LL i=0;i<m;i++) c[i]=0;
            for(LL i=0;i<n;i++) c[rank[pri[i]]]++;
            for(LL i=1;i<m;i++) c[i]+=c[i-1];
            for(LL i=n-1;i>=0;i--) sa[--c[rank[pri[i]]]]=pri[i];

            swap(rank,pri);
            p=0;rank[sa[0]]=p++;
            for(LL i=1;i<n;i++) rank[sa[i]]=(pri[sa[i]]==pri[sa[i-1]])&&(sa[i]+k<n)&&(sa[i-1]+k<n)&&(pri[sa[i]+k]==pri[sa[i-1]+k])?p-1:p++;
            if(p==n) break;
            m=p;
        }
    }

    LL H[maxn];
    void buildH()
    {
        for(LL i=0;i<n;i++) rank[sa[i]]=i;
        for(LL i=0,ans=0;i<n;i++)
        {
            if(ans) ans--;
            if(rank[i]==0) {H[rank[i]]=0;continue;}
            LL j=sa[rank[i]-1];
            while(s[i+ans]==s[j+ans]) ans++;
            H[rank[i]]=ans;
        }
    }
    LL l[3],ans[maxn],fa[maxn],cnt[maxn][3],vis[maxn];
    vector<LL> p[maxn],used;
    inline LL findset(LL x) {return fa[x]==x?x:fa[x]=findset(fa[x]);}
    inline LL getX(LL x){return x<l[1]?0:(x<l[2]?1:2);}
    void solve()
    {
        LL now=0;
        for(LL i=0;i<n;i++) {fa[i]=i;p[H[i]].push_back(i);}
        for(LL L=n;L>=1;L--)
        {
            for(LL j=0;j<p[L].size();j++)
            {
                LL P=p[L][j];vis[P]=1;used.push_back(P);
                cnt[P][getX(sa[P])]++;
                if(P>0 && vis[P-1])// merge to front
                {
                    LL front=findset(P-1); // to sa[front-1]
                    cnt[front][getX(sa[front-1])]++;
                    (now-=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod)%=mod;
                    cnt[front][getX(sa[front-1])]--;
                    for(LL i=0;i<3;i++) (cnt[front][i]+=cnt[P][i])%=mod;
                    cnt[front][getX(sa[front-1])]++;
                    (now+=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod)%=mod;
                    cnt[front][getX(sa[front-1])]--;
                    fa[P]=front;
                }
                if(P<n-1 && vis[P+1])// merge to back
                {
                    LL me=findset(P); // to sa[me-1]
                    cnt[P+1][getX(sa[P])]++;cnt[me][getX(sa[me-1])]++;
                    (now-=((cnt[P+1][0]*cnt[P+1][1]*cnt[P+1][2])%mod+(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%mod)%=mod;
                    cnt[P+1][getX(sa[P])]--;cnt[me][getX(sa[me-1])]--;
                    for(LL i=0;i<3;i++) (cnt[me][i]+=cnt[P+1][i])%=mod;
                    cnt[me][getX(sa[me-1])]++;
                    (now+=(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%=mod;
                    cnt[me][getX(sa[me-1])]--;
                    fa[P+1]=me;
                }
            }
            ans[L]=now;
        }
        for(LL i=1;i<=minlen;i++) printf("%I64d%c",ans[i],i==minlen?'\n':' ');
    }
}SA;
char tmp[maxn];
int main()
{
    LL trash='W';SA.n=0;
    scanf("%s",SA.s);SA.l[0]=SA.n;SA.n=strlen(SA.s);SA.minlen=SA.n;
    for(LL i=1;i<=2;i++)
    {
        SA.s[SA.n++]=trash++;
        SA.l[i]=SA.n;
        scanf("%s",tmp);
        LL n=strlen(tmp);SA.minlen=min(SA.minlen,n);
        for(LL j=0;j<n;j++) SA.s[SA.n++]=tmp[j];
    }
    SA.build_sa('z'+5);SA.buildH();SA.solve();
}


#define LL long long
#include<bits/stdc++.h>
using namespace std;
const LL maxn=1000000+5;
const LL mod=1000000007;
struct SuffixArray
{
    char s[maxn];
    LL minlen,n,c[maxn],rank[maxn],pri[maxn],sa[maxn];
    void build_sa(LL m)
    {
        n=strlen(s);s[n++]=0;
        for(LL i=0;i<m;i++) c[i]=0;
        for(LL i=0;i<n;i++) c[rank[i]=s[i]]++;
        for(LL i=1;i<m;i++) c[i]+=c[i-1];
        for(LL i=n-1;i>=0;i--) sa[--c[rank[i]]]=i;
        for(LL k=1;k<=n;k<<=1)
        {
            LL p=0;
            for(LL i=n-k;i<n;i++) pri[p++]=i;
            for(LL i=0;i<n;i++) if(sa[i]>=k) pri[p++]=sa[i]-k;

            for(LL i=0;i<m;i++) c[i]=0;
            for(LL i=0;i<n;i++) c[rank[pri[i]]]++;
            for(LL i=1;i<m;i++) c[i]+=c[i-1];
            for(LL i=n-1;i>=0;i--) sa[--c[rank[pri[i]]]]=pri[i];

            swap(rank,pri);
            p=0;rank[sa[0]]=p++;
            for(LL i=1;i<n;i++) rank[sa[i]]=(pri[sa[i]]==pri[sa[i-1]])&&(pri[sa[i]+k]==pri[sa[i-1]+k])?p-1:p++;
            if(p==n) break;
            m=p;
        }
    }

    LL H[maxn];
    void buildH()
    {
        for(LL i=0;i<n;i++) rank[sa[i]]=i;
        for(LL i=0,ans=0;i<n;i++)
        {
            if(ans) ans--;
            if(rank[i]==0) {H[rank[i]]=0;continue;}
            LL j=sa[rank[i]-1];
            while(s[i+ans]==s[j+ans]) ans++;
            H[rank[i]]=ans;
        }
    }
    LL l[3],ans[maxn],fa[maxn],cnt[maxn][3],vis[maxn];
    vector<LL> p[maxn],used;
    inline LL findset(LL x) {return fa[x]==x?x:fa[x]=findset(fa[x]);}
    inline LL getX(LL x){return x<l[1]?0:(x<l[2]?1:2);}
    void solve()
    {
        LL now=0;
        for(LL i=0;i<n;i++) {fa[i]=i;p[H[i]].push_back(i);}
        for(LL L=n;L>=1;L--)
        {
            for(LL j=0;j<p[L].size();j++)
            {
                LL P=p[L][j];vis[P]=1;used.push_back(P);
                cnt[P][getX(sa[P])]++;
                if(P>0 && vis[P-1])
                {
                    LL front=findset(P-1);
                    cnt[front][getX(sa[front-1])]++;(now-=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod)%=mod;cnt[front][getX(sa[front-1])]--;
                    for(LL i=0;i<3;i++) (cnt[front][i]+=cnt[P][i])%=mod;
                    cnt[front][getX(sa[front-1])]++;(((now+=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod)%=mod)+=mod)%=mod;cnt[front][getX(sa[front-1])]--;
                    fa[P]=front;
                }
                if(P<n-1 && vis[P+1])// merge to back
                {
                    LL me=findset(P); // to sa[me-1]
                    cnt[P+1][getX(sa[P])]++;cnt[me][getX(sa[me-1])]++;(now-=((cnt[P+1][0]*cnt[P+1][1]*cnt[P+1][2])%mod+(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%mod)%=mod;cnt[P+1][getX(sa[P])]--;cnt[me][getX(sa[me-1])]--;
                    for(LL i=0;i<3;i++) (cnt[me][i]+=cnt[P+1][i])%=mod;
                    cnt[me][getX(sa[me-1])]++;(((now+=(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%=mod)+=mod)%=mod;cnt[me][getX(sa[me-1])]--;
                    fa[P+1]=me;
                }
            }
            ans[L]=now;
        }
        for(LL i=1;i<=minlen;i++) printf("%I64d%c",ans[i],i==minlen?'\n':' ');
    }
}SA;
char tmp[maxn];
int main()
{
    LL trash='W';SA.n=0;
    scanf("%s",SA.s);SA.l[0]=SA.n;SA.n=strlen(SA.s);SA.minlen=SA.n;
    for(LL i=1;i<=2;i++)
    {
        SA.s[SA.n++]=trash++;
        SA.l[i]=SA.n;
        scanf("%s",tmp);
        LL n=strlen(tmp);SA.minlen=min(SA.minlen,n);
        for(LL j=0;j<n;j++) SA.s[SA.n++]=tmp[j];
    }
    SA.build_sa('z'+5);SA.buildH();SA.solve();
}


#define LL long long
#include<bits/stdc++.h>
using namespace std;
const LL maxn=1000000+5;
const LL mod=1000000007;
struct SuffixArray
{
    char s[maxn];
    LL minlen,n,c[maxn],rank[maxn],pri[maxn],sa[maxn];
    void build_sa(LL m)
    {
        n=strlen(s);s[n++]=0;
        for(LL i=0;i<m;i++) c[i]=0;
        for(LL i=0;i<n;i++) c[rank[i]=s[i]]++;
        for(LL i=1;i<m;i++) c[i]+=c[i-1];
        for(LL i=n-1;i>=0;i--) sa[--c[rank[i]]]=i;
        for(LL k=1;k<=n;k<<=1)
        {
            LL p=0;
            for(LL i=n-k;i<n;i++) pri[p++]=i;
            for(LL i=0;i<n;i++) if(sa[i]>=k) pri[p++]=sa[i]-k;

            for(LL i=0;i<m;i++) c[i]=0;
            for(LL i=0;i<n;i++) c[rank[pri[i]]]++;
            for(LL i=1;i<m;i++) c[i]+=c[i-1];
            for(LL i=n-1;i>=0;i--) sa[--c[rank[pri[i]]]]=pri[i];

            swap(rank,pri);
            p=0;rank[sa[0]]=p++;
            for(LL i=1;i<n;i++) rank[sa[i]]=(pri[sa[i]]==pri[sa[i-1]])&&(sa[i]+k<n)&&(sa[i-1]+k<n)&&(pri[sa[i]+k]==pri[sa[i-1]+k])?p-1:p++;
            if(p==n) break;
            m=p;
        }
    }

    LL H[maxn];
    void buildH()
    {
        for(LL i=0;i<n;i++) rank[sa[i]]=i;
        for(LL i=0,ans=0;i<n;i++)
        {
            if(ans) ans--;
            if(rank[i]==0) {H[rank[i]]=0;continue;}
            LL j=sa[rank[i]-1];
            while(s[i+ans]==s[j+ans]) ans++;
            H[rank[i]]=ans;
        }
    }
    LL l[3],ans[maxn],fa[maxn],cnt[maxn][3],vis[maxn];
    vector<LL> p[maxn],used;
    inline LL findset(LL x) {return fa[x]==x?x:fa[x]=findset(fa[x]);}
    inline LL getX(LL x){return x<l[1]?0:(x<l[2]?1:2);}
    void solve()
    {
        LL now=0;
        for(LL i=0;i<n;i++) {fa[i]=i;p[H[i]].push_back(i);}
        for(LL L=n;L>=1;L--)
        {
            for(LL j=0;j<p[L].size();j++)
            {
                LL P=p[L][j];vis[P]=1;used.push_back(P);
                cnt[P][getX(sa[P])]++;
                if(P>0 && vis[P-1])// merge to front
                {
                    LL front=findset(P-1); // to sa[front-1]
                    cnt[front][getX(sa[front-1])]++;
                    now-=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod;
                    cnt[front][getX(sa[front-1])]--;
                    for(LL i=0;i<3;i++) (cnt[front][i]+=cnt[P][i])%=mod;
                    cnt[front][getX(sa[front-1])]++;
                    now+=(cnt[front][0]*cnt[front][1]*cnt[front][2])%mod;
                    cnt[front][getX(sa[front-1])]--;
                    fa[P]=front;
                }
                if(P<n-1 && vis[P+1])// merge to back
                {
                    LL me=findset(P); // to sa[me-1]
                    cnt[P+1][getX(sa[P])]++;cnt[me][getX(sa[me-1])]++;
                    now-=((cnt[P+1][0]*cnt[P+1][1]*cnt[P+1][2])%mod+(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod)%mod;
                    cnt[P+1][getX(sa[P])]--;cnt[me][getX(sa[me-1])]--;
                    for(LL i=0;i<3;i++) (cnt[me][i]+=cnt[P+1][i])%=mod;
                    cnt[me][getX(sa[me-1])]++;
                    now+=(cnt[me][0]*cnt[me][1]*cnt[me][2])%mod;
                    cnt[me][getX(sa[me-1])]--;
                    fa[P+1]=me;
                }
            }
            ans[L]=now;
        }
        for(LL i=1;i<=minlen;i++) printf("%I64d%c",ans[i],i==minlen?'\n':' ');
    }
}SA;
char tmp[maxn];
int main()
{
    LL trash='W';SA.n=0;
    scanf("%s",SA.s);SA.l[0]=SA.n;SA.n=strlen(SA.s);SA.minlen=SA.n;
    for(LL i=1;i<=2;i++)
    {
        SA.s[SA.n++]=trash++;
        SA.l[i]=SA.n;
        scanf("%s",tmp);
        LL n=strlen(tmp);SA.minlen=min(SA.minlen,n);
        for(LL j=0;j<n;j++) SA.s[SA.n++]=tmp[j];
    }
    SA.build_sa('z');SA.buildH();SA.solve();
}


#include <algorithm>
#include <iostream>
#include <cassert>
#include <numeric>
#include <vector>
#include <cstdio>
using namespace std;

struct SuffixArray {
	vector<int> a, lcp;
	string s;
	int n;

	SuffixArray(const string &s): s (s) {
		n = s.size();
		calcSuffixArray();
		calcLCP();
	}

	void calcSuffixArray() {
		vector<int> b (n), key (n), cnt (max(n, 128));
		vector<bool> mark (n);
		a.resize(n);
		for(int i = 0; i < n; ++i) ++cnt[(int) s[i]];
		partial_sum(cnt.begin(), cnt.end(), cnt.begin());
		for(int i = n - 1; i >= 0; --i) a[--cnt[(int) s[i]]] = i;
		for(int i = 0; i < n; ++i) mark[i] = i == 0 || s[a[i]] != s[a[i - 1]];
		for(int k = 1; k < n; k <<= 1) {
			int nkeys = 0;
			for(int i = 0; i < n; ++i) {
				if(mark[i]) ++nkeys;
				key[a[i]] = nkeys - 1;
				b[i] = (a[i] - k + n) % n;
			}
			if(nkeys == n) break;
			fill(cnt.begin(), cnt.end(), 0);
			for(int i = 0; i < n; ++i) ++cnt[key[b[i]]];
			partial_sum(cnt.begin(), cnt.end(), cnt.begin());
			for(int i = n - 1; i >= 0; --i) a[--cnt[key[b[i]]]] = b[i];
			for(int i = 0, kv = -1; i < n; ++i) {
				int j = (a[i] + k) % n;
				if(key[j] != kv) {
					mark[i] = true;
					kv = key[j];
				}
			}
		}
		/*
		for (int i = 0; i < n; ++i)
			cout << s.substr(a[i]) << endl;
			*/
	}

	void calcLCP() {
		vector<int> rank (n);
		for(int i = 0; i < n; ++i) rank[a[i]] = i;
		lcp.resize(n);
		lcp[0] = 0;
		for(int i = 0, q = 0; i + 1 < n; ++i) {
			int j = a[rank[i] - 1];
			while(s[i + q] == s[j + q]) ++q;
			lcp[rank[i]] = q;
			if(q > 0) --q;
		}
	}
};

struct DisjointSet {
	static const int MODULO = (int) 1e9 + 7;
	vector<int> a;
	vector<int> b;
	vector<int> c;
	vector<int> lab;
	int res;

	DisjointSet (int n): a (n), b (n), c (n), lab (n, -1), res (0) {
	}

	int get(int u) {
		return lab[u] < 0 ? u : lab[u] = get(lab[u]);
	}

	void join(int u, int v) {
		u = get(u);
		v = get(v);
		assert(u != v);
		if (lab[u] < lab[v])
			swap(u, v);
		res = (res - 1LL * a[u] * b[u] * c[u]) % MODULO;
		res = (res - 1LL * a[v] * b[v] * c[v]) % MODULO;
		a[v] += a[u];
		b[v] += b[u];
		c[v] += c[u];
		lab[v] += lab[u];
		lab[u] = v;
		res = (res + 1LL * a[v] * b[v] * c[v]) % MODULO;
		if (res < 0)
			res += MODULO;
	}
};

int main() {
	ios::sync_with_stdio(false);
	string a, b, c;
	cin >> a >> b >> c;
	string s = a + (char) ('z' + 1) + b + (char) ('z' + 2) + c + (char) ('a' - 1);
	SuffixArray sa (s);
	int n = s.size();
	DisjointSet ds (n);
	for (int i = 0; i < n; ++i) {
		if (sa.a[i] <= (int) a.size())
			ds.a[i] = 1;
		else if (sa.a[i] <= (int) a.size() + 1 + (int) b.size())
			ds.b[i] = 1;
		else
			ds.c[i] = 1;
	}
	vector<pair<int, int> > v (n);
	for (int i = 1; i < n; ++i)
		v[i] = make_pair(sa.lcp[i], i);
	int m = min(min(a.size(), b.size()), c.size());
	vector<int> res (m);
	sort(v.begin(), v.end());
	for (int len = m, p = (int) v.size() - 1; len >= 1; --len) {
		//cout << "LEN = " << len << endl;
		while (p >= 0 && v[p].first == len) {
			ds.join(v[p].second - 1, v[p].second);
			//cout << v[p].second - 1 << ' ' << v[p].second << endl;
			--p;
		}
		res[len - 1] = ds.res;
	}
	for (int i = 0; i < m; ++i)
		printf("%d ", res[i]);
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cassert>
#include <numeric>
#include <vector>
#include <cstdio>
using namespace std;

struct SuffixArray {
	vector<int> a, lcp;
	string s;
	int n;

	SuffixArray(const string &s): s (s) {
		n = s.size();
		calcSuffixArray();
		calcLCP();
	}

	void calcSuffixArray() {
		vector<int> b (n), key (n), cnt (max(n, 128));
		vector<bool> mark (n);
		a.resize(n);
		for(int i = 0; i < n; ++i) ++cnt[(int) s[i]];
		partial_sum(cnt.begin(), cnt.end(), cnt.begin());
		for(int i = n - 1; i >= 0; --i) a[--cnt[(int) s[i]]] = i;
		for(int i = 0; i < n; ++i) mark[i] = i == 0 || s[a[i]] != s[a[i - 1]];
		for(int k = 1; k < n; k <<= 1) {
			int nkeys = 0;
			for(int i = 0; i < n; ++i) {
				if(mark[i]) ++nkeys;
				key[a[i]] = nkeys - 1;
				b[i] = (a[i] - k + n) % n;
			}
			if(nkeys == n) break;
			fill(cnt.begin(), cnt.end(), 0);
			for(int i = 0; i < n; ++i) ++cnt[key[b[i]]];
			partial_sum(cnt.begin(), cnt.end(), cnt.begin());
			for(int i = n - 1; i >= 0; --i) a[--cnt[key[b[i]]]] = b[i];
			for(int i = 0, kv = -1; i < n; ++i) {
				int j = (a[i] + k) % n;
				if(key[j] != kv) {
					mark[i] = true;
					kv = key[j];
				}
			}
		}
		/*
		for (int i = 0; i < n; ++i)
			cout << s.substr(a[i]) << endl;
			*/
	}

	void calcLCP() {
		vector<int> rank (n);
		for(int i = 0; i < n; ++i) rank[a[i]] = i;
		lcp.resize(n);
		lcp[0] = 0;
		for(int i = 0, q = 0; i + 1 < n; ++i) {
			int j = a[rank[i] - 1];
			while(s[i + q] == s[j + q]) ++q;
			lcp[rank[i]] = q;
			if(q > 0) --q;
		}
	}
};

struct DisjointSet {
	static const int MODULO = (int) 1e9 + 7;
	vector<int> a;
	vector<int> b;
	vector<int> c;
	vector<int> lab;
	int res;

	DisjointSet (int n): a (n), b (n), c (n), lab (n, -1), res (0) {
	}

	int get(int u) {
		return lab[u] < 0 ? u : lab[u] = get(lab[u]);
	}

	void join(int u, int v) {
		u = get(u);
		v = get(v);
		assert(u != v);
		if (lab[u] < lab[v])
			swap(u, v);
		res = (res - 1LL * a[u] * b[u] * c[u]) % MODULO;
		res = (res - 1LL * a[v] * b[v] * c[v]) % MODULO;
		a[v] += a[u];
		b[v] += b[u];
		c[v] += c[u];
		lab[v] += lab[u];
		lab[u] = v;
		res = (res + 1LL * a[v] * b[v] * c[v]) % MODULO;
		if (res < 0)
			res += MODULO;
	}
};

int main() {
	ios::sync_with_stdio(false);
	string a, b, c;
	cin >> a >> b >> c;
	string s = a + (char) ('z' + 1) + b + (char) ('z' + 2) + c + (char) ('a' - 1);
	SuffixArray sa (s);
	int n = s.size();
	DisjointSet ds (n);
	for (int i = 0; i < n; ++i) {
		if (sa.a[i] <= (int) a.size())
			ds.a[i] = 1;
		else if (sa.a[i] <= (int) a.size() + 1 + (int) b.size())
			ds.b[i] = 1;
		else
			ds.c[i] = 1;
	}
	vector<pair<int, int> > v (n);
	for (int i = 1; i < n; ++i)
		v[i] = make_pair(sa.lcp[i], i);
	int m = min(min(a.size(), b.size()), c.size());
	vector<int> res (m);
	sort(v.begin(), v.end());
	for (int len = m, p = (int) v.size() - 1; len >= 1; --len) {
		//cout << "LEN = " << len << endl;
		while (p >= 0 && v[p].first >= len) {
			ds.join(v[p].second - 1, v[p].second);
			//cout << v[p].second - 1 << ' ' << v[p].second << endl;
			--p;
		}
		res[len - 1] = ds.res;
	}
	for (int i = 0; i < m; ++i)
		printf("%d ", res[i]);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

#define mod 1000000007
#define ll long long
#define maxn 610000

struct State{
    State *suf, *go[30];
    int val;;ll right[3];
    State() :suf(0), val(0){
        memset(go, 0, sizeof(go));
    }
}*root,*last;

State statePool[maxn], *cur;

void init(){
    cur = statePool;
    root = last = cur++;
}

void extend(int w){
    State *p = last, *np = cur++;
    np->val = p->val + 1;
    while (p&&!p->go[w]) p->go[w] = np, p = p->suf;
    if (!p) np->suf = root;
    else{
        State *q = p->go[w];
        if (p->val + 1 == q->val) np->suf = q;
        else{
            State *nq = cur++;
            memcpy(nq->go, q->go, sizeof q->go);
            nq->val = p->val + 1;
            nq->suf = q->suf;
            q->suf = nq;
            np->suf = nq;
            while (p&&p->go[w] == q){
                p->go[w] = nq, p = p->suf;
            }
        }
    }
    last = np;
}

char str[maxn]; int n;
bool vis[maxn];

void dfs(State *u){
    if (vis[u - statePool]) return;
    if (!vis[u - statePool]){
        vis[u - statePool] = true;
        for (int i = 0; i < 3; i++){
            if (u->go[26 + i]) u->right[i] = 1;
        }
        for (int i = 0; i < 26; i++){
            if (u->go[i]) {
                dfs(u->go[i]);
                for (int k = 0; k < 3; k++){
                    u->right[k] = (u->right[k] + u->go[i]->right[k]) % mod;
                }
            }
        }
    }
}

ll num[maxn];

int main()
{
    init(); int n = 1e8;
    scanf("%s", str);
    n = min(n, int(strlen(str)));
    for (int i = 0; str[i]; i++) extend(str[i] - 'a');
    extend(26);

    scanf("%s", str);
    n = min(n, int(strlen(str)));
    for (int i = 0; str[i]; i++) extend(str[i] - 'a');
    extend(27);

    scanf("%s", str);
    n = min(n, int(strlen(str)));
    for (int i = 0; str[i]; i++) extend(str[i] - 'a');
    extend(28);
    dfs(root);

    int tot = cur - statePool;

    for (int i = 1; i < tot; i++){
        State *u = &statePool[i];
        ll tmp = u->right[0] % mod * u->right[1] % mod*u->right[2] % mod;
        num[u->val] = (num[u->val] + tmp) % mod;
        num[u->suf->val] = ((num[u->suf->val] - tmp) % mod + mod) % mod;
    }

    for (int i = tot-2; i >= 1; i--){
        num[i] = (num[i] + num[i + 1]) % mod;
    }
    for (int i = 1; i <= n; i++){
        if (i>1) printf(" ");
        printf("%I64d", num[i]);
    }
    puts("");
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>

#define LL long long

using namespace std;

const int maxn = 300005;
int mod = 1e9 + 7;

struct State {
    State *suf, *go[30], *nxt;
    int val, cnt; LL right[3];
    State() :
    suf(0), val(0) {
        memset(go, 0, sizeof go);
    }
    void in() {
        suf = NULL;
        memset(go, NULL, sizeof go);
        memset(right, 0, sizeof right);
        val = cnt = 0;
    }
}*root, *last;

State statePool[maxn * 2], *cur;
char s[maxn];
LL num[maxn];

void init() {
    cur = statePool;
    last = root = cur++;
}

void extend(int w) {
    State *p=last, *np=cur++;
    np->in();
    np->val=p->val+1;
    np->cnt=1;
    while(p && !p->go[w]) p->go[w] = np, p = p->suf;
    if(!p) np->suf = root;
    else {
        State *q = p->go[w];
        if(q->val == p->val + 1) np->suf = q;
        else {
            State *nq = cur++;
            nq->in();
            memcpy(nq->go, q->go, sizeof q->go);
            nq->val = p->val + 1;
            nq->suf = q->suf;
            q->suf = nq;
            np->suf = nq;
            while(p && p->go[w] == q) p->go[w] = nq, p = p->suf;
        }
    }
    last = np;
}

bool vis[maxn * 2];

void dfs(State *u) {
    if(vis[u - statePool]) return ;
    vis[u - statePool] = 1;
    for(int i = 0; i < 3; i ++) if(u->go[26 + i]) u->right[i] = 1;
    for(int i = 0; i < 26; i ++) {
        if(!u->go[i]) continue;
        dfs(u->go[i]);
        for(int j = 0; j < 3; j ++)
            u->right[j] = (u->right[j] + u->go[i]->right[j])%mod;
    }
}

int main() {
    init();
    int n = 1e9;

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(26);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(27);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(28);

    dfs(root);

    int tot = cur - statePool;
    for(int i = 1; i < tot; i ++) {
        State *p = &statePool[i];
        LL tmp = p->right[0]%mod * p->right[1] %mod * p->right[2] %mod;
        num[p->val] = (num[p->val] + tmp)%mod;
        num[p->suf->val] = ((num[p->suf->val] - tmp)%mod + mod)%mod;
    }

    for(int i = tot - 2; i > 0; i --)
        num[i] = (num[i] + num[i+1])%mod;

    for(int i = 1; i <= n; i ++) {
        printf("%I64d%s", num[i], i==n?"\n":" ");
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>

#define LL long long

using namespace std;

const int maxn = 300005;
int mod = 1e9 + 7;

struct State {
    State *suf, *go[30], *nxt;
    int val, cnt; LL right[3];
    State() :
    suf(0), val(0) {
        memset(go, 0, sizeof go);
    }
    void in() {
        suf = NULL;
        memset(go, NULL, sizeof go);
        memset(right, 0, sizeof right);
        val = cnt = 0;
    }
}*root, *last;

State statePool[maxn * 2], *cur;
char s[maxn];
LL num[maxn];

void init() {
    cur = statePool;
    last = root = cur++;
}

void extend(int w) {
    State *p=last, *np=cur++;
    np->in();
    np->val=p->val+1;
    np->cnt=1;
    while(p && !p->go[w]) p->go[w] = np, p = p->suf;
    if(!p) np->suf = root;
    else {
        State *q = p->go[w];
        if(q->val == p->val + 1) np->suf = q;
        else {
            State *nq = cur++;
            nq->in();
            memcpy(nq->go, q->go, sizeof q->go);
            nq->val = p->val + 1;
            nq->suf = q->suf;
            q->suf = nq;
            np->suf = nq;
            while(p && p->go[w] == q) p->go[w] = nq, p = p->suf;
        }
    }
    last = np;
}

bool vis[maxn * 2];

void dfs(State *u) {
    if(vis[u - statePool]) return ;
    vis[u - statePool] = 1;
    for(int i = 0; i < 3; i ++) if(u->go[26 + i]) u->right[i] = 1;
    for(int i = 0; i < 26; i ++) {
        if(!u->go[i]) continue;
        dfs(u->go[i]);
        for(int j = 0; j < 3; j ++)
            u->right[j] = (u->right[j] + u->go[i]->right[j])%mod;
    }
}

int main() {
    init();
    int n = 1e9;

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(26);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(27);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(28);

    dfs(root);

    int tot = cur - statePool;
    for(int i = 1; i < tot; i ++) {
        State *p = &statePool[i];
        LL tmp = p->right[0] * p->right[1] %mod * p->right[2] %mod;
        num[p->val] = (num[p->val] + tmp)%mod;
        num[p->suf->val] = ((num[p->suf->val] - tmp)%mod + mod)%mod;
    }

    for(int i = tot - 2; i > 0; i --) num[i] = (num[i] + num[i+1])%mod;

    for(int i = 1; i <= n; i ++) {
        printf("%I64d%s", num[i], i==n?"\n":" ");
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>

#define LL long long

using namespace std;

const int maxn = 300005;
int mod = 1e9 + 7;

struct State {
    State *suf, *go[30], *nxt;
    int val, cnt; LL right[3];
    State() :
    suf(0), val(0) {
        memset(go, 0, sizeof go);
    }
    void in() {
        suf = NULL;
        memset(go, NULL, sizeof go);
        memset(right, 0, sizeof right);
        val = cnt = 0;
    }
}*root, *last;

State statePool[maxn * 2], *cur;
char s[maxn];
LL num[maxn*2];

void init() {
    cur = statePool;
    last = root = cur++;
}

void extend(int w) {
    State *p=last, *np=cur++;
    np->in();
    np->val=p->val+1;
    np->cnt=1;
    while(p && !p->go[w]) p->go[w] = np, p = p->suf;
    if(!p) np->suf = root;
    else {
        State *q = p->go[w];
        if(q->val == p->val + 1) np->suf = q;
        else {
            State *nq = cur++;
            nq->in();
            memcpy(nq->go, q->go, sizeof q->go);
            nq->val = p->val + 1;
            nq->suf = q->suf;
            q->suf = nq;
            np->suf = nq;
            while(p && p->go[w] == q) p->go[w] = nq, p = p->suf;
        }
    }
    last = np;
}

bool vis[maxn * 2];

void dfs(State *u) {
    if(vis[u - statePool]) return ;
    vis[u - statePool] = 1;
    for(int i = 0; i < 3; i ++) if(u->go[26 + i]) u->right[i] = 1;
    for(int i = 0; i < 26; i ++) {
        if(!u->go[i]) continue;
        dfs(u->go[i]);
        for(int j = 0; j < 3; j ++)
            u->right[j] = (u->right[j] + u->go[i]->right[j])%mod;
    }
}

int main() {
    init();
    int n = 1e9;

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(26);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(27);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(28);

    dfs(root);

    int tot = cur - statePool;
    for(int i = 1; i < tot; i ++) {
        State *p = &statePool[i];
        LL tmp = p->right[0]%mod * p->right[1] %mod * p->right[2] %mod;
        num[p->val] = (num[p->val] + tmp)%mod;
        num[p->suf->val] = ((num[p->suf->val] - tmp)%mod + mod)%mod;
    }

    for(int i = tot - 2; i > 0; i --)
        num[i] = (num[i] + num[i+1])%mod;

    for(int i = 1; i <= n; i ++) {
        printf("%I64d%s", num[i], i==n?"\n":" ");
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>

#define LL long long

using namespace std;

const int maxn = 300005;
int mod = 1e9 + 7;

struct State {
    State *suf, *go[30], *nxt;
    int val, cnt; LL right[3];
    State() :
    suf(0), val(0) {
        memset(go, 0, sizeof go);
    }
    void in() {
        suf = NULL;
        memset(go, NULL, sizeof go);
        memset(right, 0, sizeof right);
        val = cnt = 0;
    }
}*root, *last;

State statePool[maxn * 2], *cur;
char s[maxn];
LL num[maxn];

void init() {
    cur = statePool;
    last = root = cur++;
}

void extend(int w) {
    State *p=last, *np=cur++;
    np->in();
    np->val=p->val+1;
    np->cnt=1;
    while(p && !p->go[w]) p->go[w] = np, p = p->suf;
    if(!p) np->suf = root;
    else {
        State *q = p->go[w];
        if(q->val == p->val + 1) np->suf = q;
        else {
            State *nq = cur++;
            nq->in();
            memcpy(nq->go, q->go, sizeof q->go);
            nq->val = p->val + 1;
            nq->suf = q->suf;
            q->suf = nq;
            np->suf = nq;
            while(p && p->go[w] == q) p->go[w] = nq, p = p->suf;
        }
    }
    last = np;
}

bool vis[maxn * 2];

void dfs(State *u) {
    if(vis[u - statePool]) return ;
    vis[u - statePool] = 1;
    for(int i = 0; i < 3; i ++) if(u->go[26 + i]) u->right[i] = 1;
    for(int i = 0; i < 26; i ++) {
        if(!u->go[i]) continue;
        dfs(u->go[i]);
        for(int j = 0; j < 3; j ++)
            u->right[j] = (u->right[j] + u->go[i]->right[j])%mod;
    }
}

int main() {
    init();
    int n = 1e9;

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(26);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(27);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(28);

    dfs(root);

    int tot = cur - statePool;
    for(int i = 1; i < tot; i ++) {
        State *p = &statePool[i];
        num[p->val] = (num[p->val] + p->right[0] * p->right[1]%mod * p->right[2] %mod)%mod;
        num[p->suf->val] = ((num[p->suf->val] - num[p->val])%mod + mod)%mod;
    }

    for(int i = tot - 2; i > 0; i --) num[i] = (num[i] + num[i+1])%mod;

    for(int i = 1; i <= n; i ++) {
        printf("%I64d%s", num[i], i==n?"\n":" ");
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>

#define LL __int64

using namespace std;

const int maxn = 300005;
int mod = 1e9 + 7;

struct State {
    State *suf, *go[30], *nxt;
    int val, cnt; LL right[3];
    State() :
    suf(0), val(0) {
        memset(go, 0, sizeof go);
    }
    void in() {
        suf = NULL;
        memset(go, NULL, sizeof go);
        memset(right, 0, sizeof right);
        val = cnt = 0;
    }
}*root, *last;

State statePool[maxn * 2], *cur;
char s[maxn];
LL num[maxn];

void init() {
    cur = statePool;
    last = root = cur++;
}

void extend(int w) {
    State *p=last, *np=cur++;
    np->in();
    np->val=p->val+1;
    np->cnt=1;
    while(p && !p->go[w]) p->go[w] = np, p = p->suf;
    if(!p) np->suf = root;
    else {
        State *q = p->go[w];
        if(q->val == p->val + 1) np->suf = q;
        else {
            State *nq = cur++;
            nq->in();
            memcpy(nq->go, q->go, sizeof q->go);
            nq->val = p->val + 1;
            nq->suf = q->suf;
            q->suf = nq;
            np->suf = nq;
            while(p && p->go[w] == q) p->go[w] = nq, p = p->suf;
        }
    }
    last = np;
}

bool vis[maxn * 2];

void dfs(State *u) {
    if(vis[u - statePool]) return ;
    vis[u - statePool] = 1;
    for(int i = 0; i < 3; i ++) if(u->go[26 + i]) u->right[i] = 1;
    for(int i = 0; i < 26; i ++) {
        if(!u->go[i]) continue;
        dfs(u->go[i]);
        for(int j = 0; j < 3; j ++)
            u->right[j] = (u->right[j] + u->go[i]->right[j])%mod;
    }
}

int main() {
    init();
    int n = 1e9;

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(26);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(27);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(28);

    dfs(root);

    int tot = cur - statePool;
    for(int i = 1; i < tot; i ++) {
        State *p = &statePool[i];
        num[p->val] = (num[p->val] + p->right[0] * p->right[1]%mod * p->right[2] %mod)%mod;
        num[p->suf->val] = ((num[p->suf->val] - num[p->val])%mod + mod)%mod;
    }

    for(int i = tot - 2; i > 0; i --) num[i] = (num[i] + num[i+1])%mod;

    for(int i = 1; i <= n; i ++) {
        printf("%I64d%s", num[i], i==n?"\n":" ");
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>

#define LL long long

using namespace std;

const int maxn = 300005;
int mod = 1e9 + 7;

struct State {
    State *suf, *go[30], *nxt;
    int val, cnt; LL right[3];
    State() :
    suf(0), val(0) {
        memset(go, 0, sizeof go);
    }
    void in() {
        suf = NULL;
        memset(go, NULL, sizeof go);
        memset(right, 0, sizeof right);
        val = cnt = 0;
    }
}*root, *last;

State statePool[maxn * 2], *cur;
char s[maxn];
LL num[maxn*2];

void init() {
    cur = statePool;
    last = root = cur++;
}

void extend(int w) {
    State *p=last, *np=cur++;
    np->in();
    np->val=p->val+1;
    np->cnt=1;
    while(p && !p->go[w]) p->go[w] = np, p = p->suf;
    if(!p) np->suf = root;
    else {
        State *q = p->go[w];
        if(q->val == p->val + 1) np->suf = q;
        else {
            State *nq = cur++;
            nq->in();
            memcpy(nq->go, q->go, sizeof q->go);
            nq->val = p->val + 1;
            nq->suf = q->suf;
            q->suf = nq;
            np->suf = nq;
            while(p && p->go[w] == q) p->go[w] = nq, p = p->suf;
        }
    }
    last = np;
}

bool vis[maxn * 2];

void dfs(State *u) {
    if(vis[u - statePool]) return ;
    vis[u - statePool] = 1;
    for(int i = 0; i < 3; i ++) if(u->go[26 + i]) u->right[i] = 1;
    for(int i = 0; i < 26; i ++) {
        if(!u->go[i]) continue;
        dfs(u->go[i]);
        for(int j = 0; j < 3; j ++)
            u->right[j] = (u->right[j] + u->go[i]->right[j])%mod;
    }
}

int main() {
    init();
    int n = 1e9;

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(26);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(27);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(28);

    dfs(root);

    int tot = cur - statePool;
    for(int i = 1; i < tot; i ++) {
        State *p = &statePool[i];
        LL tmp = p->right[0]%mod * p->right[1] %mod * p->right[2] %mod;
        num[p->val] = (num[p->val] + tmp)%mod;
        //num[p->suf->val] = ((num[p->suf->val] - tmp)%mod + mod)%mod;
    }

    for(int i = tot - 2; i > 0; i --)
        num[i] = (num[i] + num[i+1])%mod;

    for(int i = 1; i <= n; i ++) {
        printf("%I64d%s", num[i], i==n?"\n":" ");
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>

#define LL long long

using namespace std;

const int maxn = 300005;
int mod = 1e9 + 7;

struct State {
    State *suf, *go[30], *nxt;
    int val, cnt; LL right[3];
    State() :
    suf(0), val(0) {
        memset(go, 0, sizeof go);
    }
    void in() {
        suf = NULL;
        memset(go, NULL, sizeof go);
        memset(right, 0, sizeof right);
        val = cnt = 0;
    }
}*root, *last;

State statePool[maxn * 2], *cur;
char s[maxn];
LL num[maxn];

void init() {
    cur = statePool;
    last = root = cur++;
}

void extend(int w) {
    State *p=last, *np=cur++;
    np->in();
    np->val=p->val+1;
    np->cnt=1;
    while(p && !p->go[w]) p->go[w] = np, p = p->suf;
    if(!p) np->suf = root;
    else {
        State *q = p->go[w];
        if(q->val == p->val + 1) np->suf = q;
        else {
            State *nq = cur++;
            nq->in();
            memcpy(nq->go, q->go, sizeof q->go);
            nq->val = p->val + 1;
            nq->suf = q->suf;
            q->suf = nq;
            np->suf = nq;
            while(p && p->go[w] == q) p->go[w] = nq, p = p->suf;
        }
    }
    last = np;
}

bool vis[maxn * 2];

void dfs(State *u) {
    if(vis[u - statePool]) return ;
    vis[u - statePool] = 1;
    for(int i = 0; i < 3; i ++) if(u->go[26 + i]) u->right[i] = 1;
    for(int i = 0; i < 26; i ++) {
        if(!u->go[i]) continue;
        dfs(u->go[i]);
        for(int j = 0; j < 3; j ++)
            u->right[j] = (u->right[j] + u->go[i]->right[j])%mod;
    }
}

int main() {
    init();
    int n = 1e9;

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(26);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(27);

    scanf("%s", s);
    n = min(n, (int)strlen(s));
    for(int i = 0; s[i]; i ++) extend(s[i] - 'a');
    extend(28);

    dfs(root);

    int tot = cur - statePool;
    for(int i = 1; i < tot; i ++) {
        State *p = &statePool[i];
        num[p->val] = (num[p->val] + (LL)p->right[0] * p->right[1]%mod * p->right[2] %mod)%mod;
        num[p->suf->val] = ((num[p->suf->val] - num[p->val])%mod + mod)%mod;
    }

    for(int i = tot - 2; i > 0; i --) num[i] = (num[i] + num[i+1])%mod;

    for(int i = 1; i <= n; i ++) {
        printf("%I64d%s", num[i], i==n?"\n":" ");
    }
    return 0;
}


#define DEBUG 0

#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
using namespace std;

#define LL long long
#define LD long double
#define PR pair<int,int>

#define Fox(i,n) for (i=0; i<n; i++)
#define Fox1(i,n) for (i=1; i<=n; i++)
#define FoxI(i,a,b) for (i=a; i<=b; i++)
#define FoxR(i,n) for (i=(n)-1; i>=0; i--)
#define FoxR1(i,n) for (i=n; i>0; i--)
#define FoxRI(i,a,b) for (i=b; i>=a; i--)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Min(a,b) a=min(a,b)
#define Max(a,b) a=max(a,b)
#define Sz(s) int((s).size())
#define All(s) (s).begin(),(s).end()
#define Fill(s,v) memset(s,v,sizeof(s))
#define pb push_back
#define mp make_pair
#define x first
#define y second

template<typename T> T Abs(T x) { return(x<0 ? -x : x); }
template<typename T> T Sqr(T x) { return(x*x); }
string plural(string s) { return(Sz(s) && s[Sz(s)-1]=='x' ? s+"en" : s+"s"); }

const int INF = (int)1e9;
const double EPS = 1e-6;
const LD PI = acos(-1.0);

//#if DEBUG
#define GETCHAR getchar
/*#else
#define GETCHAR getchar_unlocked
#endif*/

bool Read(int &x)
{
	char c,r=0,n=0;
	x=0;
		for(;;)
		{
			c=GETCHAR();
				if ((c<0) && (!r))
					return(0);
				if ((c=='-') && (!r))
					n=1;
				else
				if ((c>='0') && (c<='9'))
					x=x*10+c-'0',r=1;
				else
				if (r)
					break;
		}
		if (n)
			x=-x;
	return(1);
}

int L;
char S[300008];
char S1[300008];
int sz,P[20][300008];
pair<PR,int> M[300008];

void BuildSuffixArray()
{
	int i,s;
		if (L==1)
		{
			sz=1;
			P[0][0]=0;
			return;
		}
		Fox(i,L)
			P[0][i]=S[i];
		for (sz=s=1; s<L; sz++,s<<=1)
		{
				Fox(i,L)
					M[i]=mp(mp(P[sz-1][i],(i+s<L ? P[sz-1][i+s] : -1)),i);
			sort(M,M+L);
				Fox(i,L)
					if ((i) && (M[i].x==M[i-1].x))
						P[sz][M[i].y]=P[sz][M[i-1].y];
					else
						P[sz][M[i].y]=i;
		}
}

int GetLCP(int i,int j)
{
	int k,lcp=0;
		for (k=sz-1; (k>=0) && (i<L) && (j<L); k--)
			if (P[k][i]==P[k][j])
			{
				i+=1<<k;
				j+=1<<k;
				lcp+=1<<k;
			}
	return(lcp);
}

#define MOD 1000000007

int par[300008],cnt[300008][3],rank[300008];

void Make(int i,int j)
{
	par[i]=i;
	cnt[i][j]=1;
}

int Find(int i)
{
		if (par[i]!=i)
			par[i]=Find(par[i]);
	return(par[i]);
}

void Merge(int i,int j)
{
	int k;
	i=Find(i);
	j=Find(j);
		if (i==j)
			return;
		if (rank[i]<rank[j])
		{
			par[i]=j;
				Fox(k,3)
				{
					cnt[j][k]+=cnt[i][k];
						if (cnt[j][k]>=MOD)
							cnt[j][k]-=MOD;
				}
		}
		else
		{
				if (rank[i]==rank[j])
					rank[i]++;
			par[j]=i;
				Fox(k,3)
				{
					cnt[i][k]+=cnt[j][k];
						if (cnt[i][k]>=MOD)
							cnt[i][k]-=MOD;
				}
		}
}

int val;

void sub(int i)
{
	i=Find(i);
		if ((cnt[i][0]) && (cnt[i][1]) && (cnt[i][2]))
		{
			int v=(LL)cnt[i][0]*cnt[i][1]%MOD*cnt[i][2]%MOD;
			val-=v;
				if (val<0)
					val+=MOD;
		}
}

void add(int i)
{
	i=Find(i);
		if ((cnt[i][0]) && (cnt[i][1]) && (cnt[i][2]))
		{
			int v=(LL)cnt[i][0]*cnt[i][1]%MOD*cnt[i][2]%MOD;
			val+=v;
				if (val>=MOD)
					val-=MOD;
		}
}

int main()
{
		if (DEBUG)
			freopen("in.txt","r",stdin);
	int i,j,k,len,mn=INF;
	int end[3];
	int nE;
	static PR E[300008];
	static int ord[300008],ans[300008];
	//string SS[3];
		Fox(i,3)
		{
			scanf("%s",&S1);
			//SS[i]=S1;
			len=strlen(S1);
			Min(mn,len);
				Fox(j,len)
					S[L++]=S1[j];
			end[i]=L;
			S[L++]=i+1;
		}
	BuildSuffixArray();
		Fox(i,L)
			ord[P[sz-1][i]]=i;
		Fox(i,L)
		{
			j=ord[i];
				if (j<end[0])
					k=0;
				else
				if (j<end[1])
					k=1;
				else
					k=2;
			Make(i,k);
		}
	nE=0;
		Fox(i,L-1)
		{
			j=GetLCP(ord[i],ord[i+1]);
				if (j)
					E[nE++]=mp(j,i);
		}
	sort(E,E+nE);
		FoxR(i,nE)
		{
			sub(E[i].y);
			sub(E[i].y+1);
			Merge(E[i].y,E[i].y+1);
			add(E[i].y);
				if ((!i) || (E[i].x!=E[i-1].x))
				{
						if (!i)
							j=1;
						else
							j=E[i-1].x+1;
						while (j<=E[i].x)
							ans[j++]=val;
				}
		}
		/*FoxR1(i,mn-1)
		{
			ans[i]+=ans[i+1];
				if (ans[i]>=MOD)
					ans[i]-=MOD;
		}*/
		Fox1(i,mn)
			printf("%d%c",ans[i],i==mn ? '\n' : ' ');
		/*Fox1(i,mn)
		{
			int a,b,c,d=0;
			string s1,s2,s3;
				Fox(a,Sz(SS[0])-i+1)
					Fox(b,Sz(SS[1])-i+1)
						Fox(c,Sz(SS[2])-i+1)
						{
							s1=SS[0].substr(a,i);
							s2=SS[1].substr(b,i);
							s3=SS[2].substr(c,i);
								if ((s1==s2) && (s2==s3))
									d++;
						}
				if (d!=ans[i])
					printf("BAD\n");
		}*/
	return(0);
}


#define DEBUG 0

#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
using namespace std;

#define LL long long
#define LD long double
#define PR pair<int,int>

#define Fox(i,n) for (i=0; i<n; i++)
#define Fox1(i,n) for (i=1; i<=n; i++)
#define FoxI(i,a,b) for (i=a; i<=b; i++)
#define FoxR(i,n) for (i=(n)-1; i>=0; i--)
#define FoxR1(i,n) for (i=n; i>0; i--)
#define FoxRI(i,a,b) for (i=b; i>=a; i--)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Min(a,b) a=min(a,b)
#define Max(a,b) a=max(a,b)
#define Sz(s) int((s).size())
#define All(s) (s).begin(),(s).end()
#define Fill(s,v) memset(s,v,sizeof(s))
#define pb push_back
#define mp make_pair
#define x first
#define y second

template<typename T> T Abs(T x) { return(x<0 ? -x : x); }
template<typename T> T Sqr(T x) { return(x*x); }
string plural(string s) { return(Sz(s) && s[Sz(s)-1]=='x' ? s+"en" : s+"s"); }

const int INF = (int)1e9;
const double EPS = 1e-6;
const LD PI = acos(-1.0);

//#if DEBUG
#define GETCHAR getchar
/*#else
#define GETCHAR getchar_unlocked
#endif*/

bool Read(int &x)
{
	char c,r=0,n=0;
	x=0;
		for(;;)
		{
			c=GETCHAR();
				if ((c<0) && (!r))
					return(0);
				if ((c=='-') && (!r))
					n=1;
				else
				if ((c>='0') && (c<='9'))
					x=x*10+c-'0',r=1;
				else
				if (r)
					break;
		}
		if (n)
			x=-x;
	return(1);
}

int L;
char S[300008];
char S1[300008];
int sz,P[20][300008];
pair<PR,int> M[300008];

void BuildSuffixArray()
{
	int i,s;
		if (L==1)
		{
			sz=1;
			P[0][0]=0;
			return;
		}
		Fox(i,L)
			P[0][i]=S[i];
		for (sz=s=1; s<L; sz++,s<<=1)
		{
				Fox(i,L)
					M[i]=mp(mp(P[sz-1][i],(i+s<L ? P[sz-1][i+s] : -1)),i);
			sort(M,M+L);
				Fox(i,L)
					if ((i) && (M[i].x==M[i-1].x))
						P[sz][M[i].y]=P[sz][M[i-1].y];
					else
						P[sz][M[i].y]=i;
		}
}

int GetLCP(int i,int j)
{
	int k,lcp=0;
		for (k=sz-1; (k>=0) && (i<L) && (j<L); k--)
			if (P[k][i]==P[k][j])
			{
				i+=1<<k;
				j+=1<<k;
				lcp+=1<<k;
			}
	return(lcp);
}

#define MOD 1000000007

int par[300008],cnt[300008][3],rank[300008];

void Make(int i,int j)
{
	par[i]=i;
	cnt[i][j]=1;
}

int Find(int i)
{
		if (par[i]!=i)
			par[i]=Find(par[i]);
	return(par[i]);
}

void Merge(int i,int j)
{
	int k;
	i=Find(i);
	j=Find(j);
		if (i==j)
			return;
		if (rank[i]<rank[j])
		{
			par[i]=j;
				Fox(k,3)
				{
					cnt[j][k]+=cnt[i][k];
						if (cnt[j][k]>=MOD)
							cnt[j][k]-=MOD;
				}
		}
		else
		{
				if (rank[i]==rank[j])
					rank[i]++;
			par[j]=i;
				Fox(k,3)
				{
					cnt[i][k]+=cnt[j][k];
						if (cnt[i][k]>=MOD)
							cnt[i][k]-=MOD;
				}
		}
}

int val;

void sub(int i)
{
	i=Find(i);
		if ((cnt[i][0]) && (cnt[i][1]) && (cnt[i][2]))
		{
			int v=(LL)cnt[i][0]*cnt[i][1]%MOD*cnt[i][2]%MOD;
			val-=v;
		}
}

void add(int i)
{
	i=Find(i);
		if ((cnt[i][0]) && (cnt[i][1]) && (cnt[i][2]))
		{
			int v=(LL)cnt[i][0]*cnt[i][1]%MOD*cnt[i][2]%MOD;
			val+=v;
		}
}

int main()
{
		if (DEBUG)
			freopen("in.txt","r",stdin);
	int i,j,k,len,mn=INF;
	int end[3];
	int nE;
	static PR E[300008];
	static int ord[300008],ans[300008];
		Fox(i,3)
		{
			scanf("%s",&S1);
			len=strlen(S1);
			Min(mn,len);
				Fox(j,len)
					S[L++]=S1[j];
			end[i]=L;
			S[L++]=i+1;
		}
	BuildSuffixArray();
		Fox(i,L)
			ord[P[sz-1][i]]=i;
		Fox(i,L)
		{
			j=ord[i];
				if (j<end[0])
					k=0;
				else
				if (j<end[1])
					k=1;
				else
					k=2;
			Make(i,k);
		}
	nE=0;
		Fox(i,L-1)
		{
			j=GetLCP(ord[i],ord[i+1]);
				if (j)
					E[nE++]=mp(j,i);
		}
	sort(E,E+nE);
		FoxR(i,nE)
		{
			sub(E[i].y);
			sub(E[i].y+1);
			Merge(E[i].y,E[i].y+1);
			add(E[i].y);
				if ((!i) || (E[i].x!=E[i-1].x))
				{
						if (!i)
							j=1;
						else
							j=E[i-1].x+1;
						while (j<=E[i].x)
							ans[j++]=val;
				}
		}
		/*FoxR1(i,mn-1)
		{
			ans[i]+=ans[i+1];
				if (ans[i]>=MOD)
					ans[i]-=MOD;
		}*/
		Fox1(i,mn)
			printf("%d%c",ans[i],i==mn ? '\n' : ' ');
	return(0);
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>

using namespace std;

#define sd(x) scanf("%d",&x);
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Fill(a, b) memset(a, b, sizeof(a))
#define INF 2000000009

typedef pair<int,int> PII;
typedef vector<int> VI;

#define MAXN 300010
#define MAXLG 22
#define INF 1000000009

int mod=1000000007;

int tree1[MAXN],tree2[MAXN],tree3[MAXN],x,y,ma[MAXN][MAXLG],l,last[MAXN],idx[MAXN];

LL ans[MAXN];

void update(int idx ,int val,int tree[])
{
	while (idx <= MAXN)
    {
		tree[idx] += val;
		idx += (idx & -idx);
	}
}
int read(int idx,int tree[])
{
	int sum = 0;
	while (idx > 0)
    {
		sum += tree[idx];
		idx -= (idx & -idx);
	}
	return sum;
}

struct entry
{
    int nr[2];
    int p;
} L[MAXN];

int P[MAXLG][MAXN];
int N,i;
int stp, cnt,ar[MAXN],comp[MAXN];

int cmp(entry a, entry b)
{
    if (a.nr[0]!=b.nr[0]) return a.nr[0]<b.nr[0];
    else return a.nr[1]<b.nr[1];
}

int FindLCP (int x,int y)
{
    int ans = 0 , k=0 , tmp=cnt;
    for (k=stp-1;k>= 0;k--,tmp>>=1)
    {
        if (x+tmp <= N && y+tmp <= N && P[k][x] == P[k][y])
        {// sort-index is same if the first k characters are same
            ans += tmp;
            // now we wish to find the characters that are same in the remaining strings
            x += tmp;
            y += tmp;
		}
	}
	return ans;
}

int rmq(int x,int y)
{
    int n=y-x+1,i=x,j=0,ans=x;
    while(n)
    {
        if(n&1)
        {
            if(ar[ans]>ar[ma[i][j]])ans=ma[i][j];
            i=i+(1<<j);
        }
        n>>=1;
        j++;

    }
    return ans;
}

void bin(int a,int b)
{
	if(a>=b)return;
	int mid=rmq(a,b);
	if(ar[mid]>l)return;
	LL x=read(b+1,tree1)-read(a-1,tree1);
	LL y=read(b+1,tree2)-read(a-1,tree2);
	LL z=read(b+1,tree3)-read(a-1,tree3);//cout<<a<<b<<mid<<x<<y<<z<<" "<<ar[mid]<<" "<<x*y*z<<endl;
	if(ar[mid]>last[a])
	{   //if(ar[mid]==3)cout<<a<<" "<<b<<mid<<x<<y<<z<<" "<<ar[mid]<<" "<<x*y*z<<endl;
		x=(x*y*z)%mod;
		ans[ar[mid]]+=x;
		ans[last[a]]-=x;
	}
	last[a]=ar[mid];
	last[mid+1]=ar[mid];
	bin(a,mid-1);
	bin(mid+1,b);
}

void solve()
{
    for(stp=1, cnt = 1; cnt < N; stp++, cnt *= 2)
    {
        for(i=0; i < N; i++)
        {
            L[i].nr[0]=P[stp- 1][i];
            L[i].nr[1]=i +cnt <N? P[stp -1][i+ cnt]:-1;
            L[i].p= i;
        }
        sort(L, L+N, cmp);
        for(i=0; i < N; i++)
            P[stp][L[i].p] =(((i> 0) && (L[i].nr[0]==L[i-1].nr[0]) && (L[i].nr[1] == L[i- 1].nr[1])) ? P[stp][L[i-1].p] : i);
    }
    //long long ans=N;
    //ans=(ans*(ans+1))/2;
    for(int i=0;i<N;i++)
    {
		if(i<=x)idx[i]=1;
		else if(i<=y)idx[i]=2;
		else idx[i]=3;
    }
    for(int i=0;i<N-1;i++)
    {
		ar[i]=FindLCP(L[i].p,L[i+1].p);
		//cout<<i<<" "<<ar[i]<<endl;
    }
    for(int i=0;i<N;i++)
    {
		if(L[i].p>y)update(i,1,tree3);
		else if(L[i].p>x&&L[i].p<y)update(i,1,tree2);
		else if(L[i].p<x)update(i,1,tree1);
		ma[i][0]=i;
    }

    for(int j=1;(1<<j)<=N-1;j++)
    {
        for(int i=0;(i+(1<<j))<=N-1;i++)
        {
            if(ar[ma[i][j-1]]<ar[ma[i+(1<<(j-1))][j-1]])
            {
                ma[i][j]=ma[i][j-1];
            }
            else ma[i][j]=ma[i+(1<<(j-1))][j-1];
        }
    }//cout<<"aman "<<N<<endl;
    bin(2,N-2);
    for(int i=l-1;i>=1;i--)
    {//cout<<ans[i]<<endl;
		ans[i]+=ans[i+1];
    }
    for(int i=1;i<=l;i++)
    {
		if(i!=1)cout<<" ";
		cout<<ans[i];
    }
    cout<<endl;

}
int main()
{
	int t=1,tmp,last;
	string a,b,c,s;
	//scanf("%d",&t);
	while(t--)
	{
		cin>>a>>b>>c;
		x=a.length();
		l=min(min(a.length(),b.length()),c.length());
		y=x+b.length()+1;
		s=a+"&"+b+"$"+c;
		N=s.length();
		for(int i=0;i<N;i++)P[0][i] = s[i];
		solve();
	}
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>

using namespace std;

#define sd(x) scanf("%d",&x);
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Fill(a, b) memset(a, b, sizeof(a))
#define INF 2000000009

typedef pair<int,int> PII;
typedef vector<int> VI;

#define MAXN 300010
#define MAXLG 22
#define INF 1000000009

int mod=1000000007;

int tree1[MAXN],tree2[MAXN],tree3[MAXN],x,y,ma[MAXN][MAXLG],l,last[MAXN];

LL ans[MAXN];

void update(int idx ,int val,int tree[])
{
	while (idx <= MAXN)
    {
		tree[idx] += val;
		idx += (idx & -idx);
	}
}
int read(int idx,int tree[])
{
	int sum = 0;
	while (idx > 0)
    {
		sum += tree[idx];
		idx -= (idx & -idx);
	}
	return sum;
}

struct entry
{
    int nr[2];
    int p;
} L[MAXN];

int P[MAXLG][MAXN];
int N,i;
int stp, cnt,ar[MAXN],comp[MAXN];

int cmp(entry a, entry b)
{
    if (a.nr[0]!=b.nr[0]) return a.nr[0]<b.nr[0];
    else return a.nr[1]<b.nr[1];
}

int FindLCP (int x,int y)
{
    int ans = 0 , k=0 , tmp=cnt;
    for (k=stp-1;k>= 0;k--,tmp>>=1)
    {
        if (x+tmp <= N && y+tmp <= N && P[k][x] == P[k][y])
        {// sort-index is same if the first k characters are same
            ans += tmp;
            // now we wish to find the characters that are same in the remaining strings
            x += tmp;
            y += tmp;
		}
	}
	return ans;
}

int rmq(int x,int y)
{
    int n=y-x+1,i=x,j=0,ans=x;
    while(n)
    {
        if(n&1)
        {
            if(ar[ans]>ar[ma[i][j]])ans=ma[i][j];
            i=i+(1<<j);
        }
        n>>=1;
        j++;

    }
    return ans;
}

void bin(int a,int b)
{
	if(a>=b)return;
	int mid=rmq(a,b);
	LL x=read(b+1,tree1)-read(a-1,tree1);
	LL y=read(b+1,tree2)-read(a-1,tree2);
	LL z=read(b+1,tree3)-read(a-1,tree3);//cout<<a<<b<<mid<<x<<y<<z<<" "<<ar[mid]<<" "<<x*y*z<<endl;
	if(ar[mid]!=last[a])
	{//cout<<a<<b<<mid<<x<<y<<z<<" "<<ar[mid]<<" "<<x*y*z<<endl;
		x=(x*y*z)%mod;
		ans[ar[mid]]+=x;
		ans[last[a]]-=x;
		last[a]=ar[mid];
		last[mid+1]=ar[mid];
	}
	bin(a,mid-1);
	bin(mid+1,b);
}

void solve()
{
    for(stp=1, cnt = 1; cnt < N; stp++, cnt *= 2)
    {
        for(i=0; i < N; i++)
        {
            L[i].nr[0]=P[stp- 1][i];
            L[i].nr[1]=i +cnt <N? P[stp -1][i+ cnt]:-1;
            L[i].p= i;
        }
        sort(L, L+N, cmp);
        for(i=0; i < N; i++)
            P[stp][L[i].p] =(((i> 0) && (L[i].nr[0]==L[i-1].nr[0]) && (L[i].nr[1] == L[i- 1].nr[1])) ? P[stp][L[i-1].p] : i);
    }
    //long long ans=N;
    //ans=(ans*(ans+1))/2;
    for(int i=0;i<N-1;i++)
    {
		ar[i]=FindLCP(L[i].p,L[i+1].p);
		//cout<<ar[i]<<endl;
    }
    for(int i=0;i<N;i++)
    {
		if(L[i].p>y)update(i,1,tree3);
		else if(L[i].p>x&&L[i].p<y)update(i,1,tree2);
		else if(L[i].p<x)update(i,1,tree1);
		ma[i][0]=i;
    }

    for(int j=1;(1<<j)<=N-1;j++)
    {
        for(int i=0;(i+(1<<j))<=N-1;i++)
        {
            if(ar[ma[i][j-1]]<ar[ma[i+(1<<(j-1))][j-1]])
            {
                ma[i][j]=ma[i][j-1];
            }
            else ma[i][j]=ma[i+(1<<(j-1))][j-1];
        }
    }//cout<<"aman "<<N<<endl;
    bin(2,N-2);
    for(int i=l-1;i>=1;i--)
    {//cout<<ans[i]<<endl;
		ans[i]+=ans[i+1];
    }
    for(int i=1;i<=l;i++)
    {
		if(i!=1)cout<<" ";
		cout<<ans[i];
    }
    cout<<endl;

}
int main()
{
	int t=1,tmp,last;
	string a,b,c,s;
	//scanf("%d",&t);
	while(t--)
	{
		cin>>a>>b>>c;
		x=a.length();
		l=min(min(a.length(),b.length()),c.length());
		y=x+b.length()+1;
		s=a+"&"+b+"$"+c;
		N=s.length();
		for(int i=0;i<N;i++)P[0][i] = s[i];
		solve();
	}
}


#include <bits/stdc++.h>
#include<math.h>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	long long l,r;
	int t;
	scanf("%I64d %I64d %d",&l,&r,&t);
	long long s=1;
	int q=0;
	if(l==1) {
		q=1;
		printf("1 ");
	}
	long long w=1;
	for(int i=1;i<100;i++){
		w*=t;
		if(w>r/t and w<=r) break;
	}
	for(int i=1;i<=100;i++){
		s*=t;
		if(s>=l and s<w) {printf("%I64d ",s);q=1;}
		if(s==w and w>1) {
			printf("%I64d",w);
			break;
		}
	}
	if(q==0) printf("-1");
    return 0;
}


#include<iostream>
using namespace std;
int p(int n,int k)
{
	if(k>0) return p(n,k-1)*n;
	return 1;
}
int main()
{
	int cnt=0,l,r,n;
	cin>>l>>r>>n;
	for(int i=l;i<=r;i++)
	{
		for(int j=0;j<=r/2;j++)
		{
			if(i==p(n,j))
			{
				cnt++;
				if(cnt==0) break;
				else cout<<i<<" ";
			}
		}
	}
	if(cnt==0) cout<<"-1";
	return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<climits>
#include<vector>
using namespace std;
bool tmp=1;
int main()
{
    long long l,r,k;
    long long n=1;
    cin>>l>>r>>k;
    for(int i=1;;i++)
    {
    	if(n>=l && n<=r)
    	{
    		cout<<n<<" ";
    		tmp=0;
    	}
    	else
    	{
    		break;
    	}
    	n=n*k;
    }
    if(tmp==1)
    {
    	cout<<-1;
    }
    return 0;
}


#include<bits/stdc++.h>
int main()
{
	int i,s=0;
	long long l,r,k=1,k1;
	scanf("%lld%lld%lld",&l,&r,&k1);
	for(i=1;k<r;i++){
		if((k>=l)&&(k<=r)){
			printf("%lld ",k);
			s=1;
		}
		k*=k1;
	}
	if(s==0)
	printf("-1\n");
	else
	printf("\n");
}


#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	long long l,r,k,m=1;
	bool f=0;
	cin>>l>>r>>k;
	if(k==1)
	{
		if(l==1)
		{
			f=1;
			cout<<1;
		}
	}else{
		while(m<=r)
		{
			if(m>=l)
			{
				if(!f) cout<<m;
				else cout<<' '<<m;
				f=1;
			}
			if(m>r/k) break;
			m*=k;
		}
	}
	if(!f) cout<<-1;
	cout<<endl;
	return 0;
}


#include<iostream>
using namespace std;
int p(int n,int k)
{
	if(k>0) return p(n,k-1)*n;
	else return 1;
}
int main()
{
	int cnt=0,l,r,n;
	cin>>l>>r>>n;
	for(int i=l;i<=r;i++)
	{
		for(int j=0;j<=r/2;j++)
		{
			if(i==p(n,j))
			{
				cnt++;
				if(cnt==0) break;
				else cout<<i<<" ";
			}
		}
	}
	if(cnt==0) cout<<"-1";
	return 0;
}


#include<bits/stdc++.h>
int main()
{
	int i,k1,s=0;
	long long l,r,k=1;
	scanf("%lld%lld%d",&l,&r,&k1);
	for(i=1;k<r;i++){
		if((k>=l)&&(k<=r)){
			printf("%d ",k);
			s=1;
		}
		k*=k1;
	}
	if(s==0)
	printf("-1\n");
	else
	printf("\n");
}


// luogu-judger-enable-o2
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>
long long r, k, l, p=1;
int main ()
{
	scanf("%lld %lld %lld",&l,&r,&k);
	if(k==1){
		if(l==1) printf("1");
		else printf("-1");
		return 0;
	}
	while (p<l) p*=k;
	bool pd=false;
	while (p<=r&&p>=l){
		printf("%lld ",p);
		pd=true;
		p*=k;
	}
	if(pd==true)printf("\n");
	else printf("-1");
	return 0;
}


#include<bits/stdc++.h>
#define ull unsigned long long

using namespace std;

ull n,ts;
ull l,r,w;

long long gcd(long long a,long long b){
    return (a%b==0)?b:gcd(b,a%b);
}

int main (){
	cin >> l >> r >> w;
	for(int i=0;pow(w,i)<=r;i++){
		if(pow(w,i)>=l&&pow(w,i)<=r) cout << pow(w,i) << " ",ts=1;
	}
	if(!ts) cout << -1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long l,r,k;
long long ans =1,f;//ans是用来存每次乘出来的结果的，f是用来存是否有输出的
int main(){
    cin>>l>>r>>k;
    if(k==1){//特判
        if(l==1)
		cout<<1<<endl;
        else
		cout<<-1<<endl;
        return 0;
    }
    while(1){
        if(ans>=l&&ans<=r){//如果ans在l到r这个范围内，就可以输出
            cout<<ans<<' ';
            f=1;//如果有输出，就标记f为1
        }
        if(ans>=r||r/ans<k)
			break;
        //如果ans此刻的值已经超过了它能到达的最大值
        //或者是再乘下一个数就会超过r，则结束。
        //ps:这里不写成ans*k>r，是因为此刻ans再乘k的值可能会超过longlong导致变成负数出错，所以把不等式变形一下，写成r/ans<k
        ans*=k;
    }
    if(!f)
	cout<<-1;//如果没有输出的话，就输出-1
	return 0;
}


#include <iostream>
using namespace std;

int main() {
    long long l, r, k;
    cin >> l >> r >> k;
    int sum = 0;
    if(k == 1) {
        if(l == 1) {
            cout << 1 << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }
    for(int i = 1; ; i*=k) {
        if(i >= l && i <= r) {
            sum++;
            cout << i << " ";
        }
        if(i > r) {
            break;
        }
    }
    if(sum == 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long double l,r,w,s,n=1;
int main(){
    cin>>l>>r>>w;
    if(w==1){
    if(l==1){
    cout<<1;
    }
	else{
    cout<<-1<<endl;
    return 0;
    }}
    while(n<l){
    n*=w;
    }
    while(n>=l && n<=r){
    cout<<(long long)n<<" ";
    n*=w;
    s++;
    }
    if(s==0){
    cout<<-1;
	}
    return 0;
}


#include<cstdio>
#include<cmath>
long long l,r,k,x;
long long quickpow(long long x,long long y)
{
	long long res=1ll;
	while(y)
	{
		if(y&1ll) res*=x;
		x*=x;
		y>>=1ll;
	}
	return res;
}
int main()
{
	scanf("%lld%lld%lld",&l,&r,&k);
	if(log(1.0*r)/log(1.0*k)<1.0) printf("-1\n");
	else
	{
		x=quickpow(k,int(log(1.0*l)/log(1.0*k)));
		while(x<=r)
		{
			if(x>=l&&x<=r) printf("%lld ",x);
			x*=k;
		}
	}
	return 0;
}


#include<iostream>
using namespace std;
int p(int n,int k)
{
	if(k>0) return p(n,k-1)*n;
	else return 1;
}
int main()
{
	int cnt=0,l,r,n;
	cin>>l>>r>>n;
	for(int i=l;i<=r;i++)
	{
		for(int j=0;j<=r/2;i++)
		{
			if(i==p(n,j))
			{
				cnt++;
				if(cnt==0) break;
				else cout<<i<<" ";
			}
		}
	}
	if(cnt==0) cout<<"-1";
	return 0;
}


#include<iostream>
using namespace std;
#pragma GCC optimize(2)

int p(int n,int k)
{
	if(k>0) return p(n,k-1)*n;
	else return 1;
}
int main()
{
	int cnt=0,l,r,n;
	cin>>l>>r>>n;
	for(int i=l;i<=r;i++)
	{
		for(int j=0;j<=r/2;j++)
		{
			if(i==p(n,j))
			{
				cnt++;
				if(cnt==0) break;
				else cout<<i<<" ";
			}
		}
	}
	if(cnt==0) cout<<"-1";
	return 0;
}


# include "bits/stdc++.h"
# define fp(c, k, a) for (register int c = k; c <= a; c++)
# define fq(c, k, a) for (register int c = k; c >= a; c--)
# pragma GCC optimize (2)
# define ul long double
using namespace std;
ul l, r, k;
bool flag = 0;
inline void mn (int &a, int b) {a = a < b ? a : b;}
inline void mx (int &a, int b) {a = a > b ? a : b;}
int main () {
	cin >> l >> r >> k;
	ul t = 1;
	if (1 >= l && 1 <= r) {
		cout << 1 << ' ';
	}
	if (k == 1) {
		puts ("-1");
		return 0;
	}
	while (1) {
		t *= k;
		if (t < l) continue;
		if (t > r) break;
		cout << (unsigned long long)t << ' ';
		flag = 1;
	}
	if (!flag) puts ("-1");
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
long long n,m,k,flag;
int main(){
	cin>>n>>m>>k;
	long long sum=1;
	while(sum<=m){
		if(sum>=n)cout<<sum<<' ',flag=1;
		if(m/k<sum)break;
		sum*=k;
	}
	if(!flag)cout<<-1;
}


#include<iostream>
using namespace std;
int p(int n,int k)
{
	if(k>0) return p(n,k-1)*n;
	else return 1;
}
int main()
{
	int cnt=0,l,r,n;
	cin>>l>>r>>n;
	for(int i=l;i<=r;i++)
		for(int j=0;j<=r/2;j++)
			if(i==p(n,j))
			{
				cnt++;
				if(cnt==0) break;
				else cout<<i<<" ";
			}
	if(cnt==0) cout<<"-1";
	return 0;
}


#include<iostream>
#include<cmath>
using namespace std;
int main() {
  long long l,r,k;
  int f=0;
  cin>>l>>r>>k;
  long long ans=1;
  for(long long i=l;i<=r;i++) {
    if(ans>=l&&ans<=r) {
      printf("%lld ",ans);
      f=1;
    }
    ans*=k;
    if(ans>r)
    break;
  }
  if(!f)
  cout<<-1;
}


#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <string>
#include <string.h>
#include <set>
#include <queue>
#include <stdbool.h>

#define LL long long
using namespace std;
const int maxn = 1e5 + 10;

LL L,R;
LL k;
LL arr[maxn];

int main(){
    cin >> L >> R >> k;
    LL cnt = 0;
    LL ans = 1;
    while (ans < L){
        ans *= k;
    }
    while (ans<=R){
        if (R/ans < k || ans >= R)
            break;
        arr[cnt++] = ans;
        ans *= k;
    }
    if (cnt == 0){
        printf("-1\n");
    }
    else{
        for (int i=0;i<cnt;i++){
            printf("%lld ",arr[i]);
        }
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <set>
#include <climits>
#include <functional>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))	        \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef long long				LLONG;

inline int read() {
	int ret = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
	return ret * f;
}//快读优化

int main(int argc, char* argv[])
{
	LLONG		llLeft;
	LLONG		llRight;
	LLONG		llBaseNumber;
	LLONG		llResult				= 1;
	LLONG		llIndex					= 0;
	BOOL		bFlag					= 0;

	cin >> llLeft >> llRight >> llBaseNumber;

	if (llLeft == 1)
	{
		bFlag = 1;
		cout << 1 << " ";
	}

	if (llBaseNumber > 1)
	{
		while (llResult < llLeft / llBaseNumber || (llResult == llLeft / llBaseNumber && (llLeft % llBaseNumber)))
		{
			llResult *= llBaseNumber;
		} // 使 llResult 不小于 llLeft;

		while (llResult <= llRight / llBaseNumber)
		{
			llResult *= llBaseNumber;
			bFlag = 1;
			cout << llResult << " ";
		} // 开始找数字
	}

	if (!bFlag)
	{
		cout << -1;
	}
	cout << endl;
	return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<climits>
#include<vector>
using namespace std;
bool tmp=1;
int main()
{
    long long l,r,k;
    long long n=1;
    cin>>l>>r>>k;
    if(k==1)
    {
        if(l==1)
        {
            cout<<1<<endl;
        }
        else
        {
            cout<<-1<<endl;
        }
        return 0;
    }
    for(int i=1;;i++)
    {
    	if(n>=l && n<=r)
    	{
    		cout<<n<<" ";
    		tmp=0;
    	}
    	if(n>=r)
    	{
    		break;
    	}
    	n=n*k;
    }
    if(tmp==1)
    {
    	cout<<-1;
    }
    return 0;
}


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

typedef long long ll;

ll Power(ll a, ll b)
{
	if(b == 0) return 1;
	if(b == 1) return a;
	ll ans = Power(a, b/2);
	ans *= ans;
	if(b&1) ans *= a;
	return ans;
}

int main(void)
{
	ll l, r, k, a, b;
	cin>>l>>r>>k;
	if(k == 1)
	{
		printf("-1");
		return 0;
	}
	a = l;
	b = r;
	ll n1 = 0, n2 = 0;
	a /= k;
	while(a)
	{
		n1++;
		a /= k;
	}
	b /= k;
	while(b)
	{
		n2++;
		b /= k;
	}
	ll tmp = Power(k, n1);
	if(n1 == n2 && tmp < l)
	{
		printf("-1");
		return 0;
	}
	int flag = 0;
	if(tmp < l)
	{
		tmp *= k;
	}
	while(tmp <= r)
	{
		if(!flag)
		{
			flag = 1;
			printf("%lld", tmp);
		}
		else printf(" %lld", tmp);
		tmp *= k;
	}
	if(!flag) printf("-1");

	return 0;
}


#include<iostream>
using namespace std;
int p(int n,int k)
{
	if(k>0) return p(n,k-1)*n;
	else return 1;
}
int main()
{
	int cnt=0,l,r,n;
	cin>>l>>r>>n;
	for(int i=l;i<=r;i++)
	{
		for(int j=0;j<=r/2;j++)
		{
			if(i==p(n,j))
			{
				++cnt;
				if(cnt==0) break;
				else cout<<i<<" ";
			}
		}
	}
	if(cnt==0) cout<<"-1";
	return 0;
}


# include "bits/stdc++.h"
# define fp(c, k, a) for (register int c = k; c <= a; c++)
# define fq(c, k, a) for (register int c = k; c >= a; c--)
# pragma GCC optimize (2)
# define ul unsigned long long
using namespace std;
ul l, r, k;
bool flag = 0;
inline void mn (int &a, int b) {a = a < b ? a : b;}
inline void mx (int &a, int b) {a = a > b ? a : b;}
int main () {
    cin >> l >> r >> k;
    ul t = 1;
    if (t >= l && t <= r) {
        cout << t << ' ';
    }
    if (k == 1) {
		printf ("-1");
		return 0;
	}
    while (1) {
        t *= k;
        if (t < l) continue;
        if (t > r) break;
        cout << t << ' ';
        flag = 1;
    }
    if (!flag) printf ("-1");
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	long long l,r,i,k=1;
	int a=0;
	cin>>l>>r>>i;
	if(l==1)
	{
		printf("1 ");
		a=1;
	}
	if(r>1)
	{
		while(k<=l/i)
			k*=i;
        while(k<=r/i)
        {
            k*=i;
            a=1;
            printf("%lld ",k);
        }
	}
	if(!a)printf("-1");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int p(int n,int k)
{
	if(k>0)
	{
		return p(n,k-1)*n;
	}
	else return 1;
}

int main()
{
	int cnt=0,l,r,n;
	cin>>l>>r>>n;
	for(int i=l;i<=r;i++)
	{
		for(int j=0;j<=r;j++)
		{
			if(i==p(n,j))
			{
				cnt++;
				if(cnt>0)
					cout<<i<<" ";
				else
					cout<<"-1";
			}
		}
	}
	return 0;
}


#include<cstdio>
#include<cmath>
using namespace std;
long long l,r,w,sum=1,t;
int main()
{
	scanf("%lld %lld %lld",&l,&r,&w);
	if(w==1)
		printf("1");
	else
	{
		for(;;)
		{
			if(l<=sum)
			{
				t=1;
				printf("%lld ",sum);
			}
			if(sum>r/w)
				break;
			sum*=w;
		}
		if(!t)
			printf("-1");
	}
}


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

#define int long long
#define re register

int l,r,k;

signed main()
{
	scanf("%lld%lld%lld",&l,&r,&k);
	int ans=0;bool flag=0;
	for(re int sum=1;sum<=r;sum*=k)
	{
		if(sum>=l&&sum<=r)printf("%lld ",sum),flag=1;
	}
	if(!flag)puts("-1");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	long long l,r,i,k=1;
	int a=0;
	cin>>l>>r>>i;
	if(l==1)
	{
		printf("1 ");
		a=1;
	}
	if(i>1)
	{
        while(k<=r/i)
        {
            k*=i;
            if(k<=l/i)continue;
			a=1;
            printf("%lld ",k);
        }
	}
	if(!a)printf("-1");
	return 0;
}


#include<bits/stdc++.h>
#define Open(s) freopen(s".in","r",stdin);freopen(s".out","w",stdout);
#define ri register int
using namespace std;
long long l, r, k;
long long ans = 1, f;
int main()
{
    //Open("");
    cin >> l >> r >> k;
    if(k == 1)
    {
        if(l == 1) cout << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }
    while (1)
    {
    	if (ans >= l && ans <= r)
        {
            cout << ans << ' ';
            f = 1;
        }
        if (ans >= r) break;
    	ans *= k;
    }
    if (!f) cout << -1;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int l,r,p=1;
long double k,i=1.0,q;
signed main(){
	cin>>l>>r>>k;
	while(i<=r){
		q=i;
		if(i>=l) cout<<(int)i<<' ',p=0;
		i*=k;
		if(i<=q) break;
	}
	if(p) cout<<"-1";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool tmp=1;
int main(){
    long long l,r,k,n=1;
    cin>>l>>r>>k;
    if(k==1){
        if(l==1)cout<<1<<endl;
        else cout<<-1<<endl;
        return 0;
    }
    for(int i=1;;i++){
        if(n>=l && n<=r){
            cout<<n<<" ";tmp=0;
        }
        if(n>=r||r/n<k)break;
        n=n*k;
    }
    if(tmp==1)cout<<-1;
    return 0;
}


#include<stdio.h>
using namespace std;
int main(){
	unsigned long long l,r,k,now=1;
	int flag=1;
	scanf("%u%u%u",&l,&r,&k);
	while(now<=r){
		if(now>=l){
			printf("%u ",now);flag=0;
		}
		now*=k;
	}
	if(flag)printf("-1");
	return 0;
}


#include<iostream>
int p(int n,int k)
{
	if(k>0) return p(n,k-1)*n;
	else return 1;
}
int main()
{
	int cnt=0,l,r,n;
	std::cin>>l>>r>>n;
	for(int i=l;i<=r;i++)
	{
		for(int j=0;j<=r/2;j++)
		{
			if(i==p(n,j))
			{
				cnt++;
				if(cnt==0) break;
				else std::cout<<i<<" ";
			}
		}
	}
	if(cnt==0) std::cout<<"-1";
	return 0;
}


#include<iostream>
using namespace std;
#pragma GCC optimize(3,"Ofast","inline")

int p(int n,int k)
{
	if(k>0) return p(n,k-1)*n;
	else return 1;
}
int main()
{
	int cnt=0,l,r,n;
	cin>>l>>r>>n;
	for(int i=l;i<=r;i++)
	{
		for(int j=0;j<=r/2;j++)
		{
			if(i==p(n,j))
			{
				cnt++;
				if(cnt==0) break;
				else cout<<i<<" ";
			}
		}
	}
	if(cnt==0) cout<<"-1";
	return 0;
}


#include<iostream>
using namespace std;
int p(int n,int k)
{
	if(k>0)
	{
		return p(n,k-1)*n;
	}
	else return 1;
}

int main()
{
	double cnt=0,l,r,n;
	cin>>l>>r>>n;
	for(int i=l;i<=r;i++)
	{
		for(int j=0;j<=r/2;j++)
		{
			if(i==p(n,j))
			{
				cnt++;
				if(cnt==0)
				{
					break;
				}
				else
					cout<<i<<" ";
			}

		}
	}
	if(cnt==0)
		cout<<"-1";

	return 0;
}


#include<cstdio>
#include<iostream>
using namespace std;
long double l,r,w,cnt,wn=1;
int main()
{
	ios::sync_with_stdio(0);
    cin>>l>>r>>w;
    if(w==1)
    {
        if(l==1)cout<<1<<endl;
        else cout<<-1<<endl;
        return 0;
    }
    while(wn<l)wn*=w;
    while(wn>=l&&wn<=r)
    {
        cout<<(long long)wn<<' ';
        wn*=w;
        cnt++;
    }
    if(!cnt)cout<<-1<<endl;
    else cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int l,r,p=1;
long double k,i=1.0,q;
signed main(){
	cin>>l>>r>>k;
	while(i<=r){
		q=i;
		if(i>=l) cout<<i<<' ',p=0;
		i*=k;
		if(i<=q) break;
	}
	if(p) cout<<"-1";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,m,k;
int main(){
	cin>>n>>m>>k;
	int r=0,h=k,t=0;
	if(n==1)r=1,cout<<1<<" ";
	while(k<=m){
		if(k>=n)cout<<k<<" ";
		k*=h;
		r=1;
	}
	if(r==0)cout<<-1;
	return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<climits>
#include<vector>
using namespace std;
bool tmp=1;
int main()
{
    long long l,r,k;
    long long n=1;
    cin>>l>>r>>k;

    for(int i=1;;i++)
    {
    	if(n>=l && n<=r)
    	{
    		cout<<n<<" ";
    		tmp=0;
    	}
    	if(n>=r)
    	{
    		break;
    	}
    	n=n*k;
    }
    if(tmp==1)
    {
    	cout<<-1;
    }
    return 0;
}


#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
    int l, r, k;
    scanf("%d %d %d", &l, &r, &k);
    for (int i = 0; ; i++) {
        int res = pow(k, i);
        if (res < l) continue;
        else if (res > r) break;
        printf("%d ", res);
    }
    putchar('\n');
    return 0;
}


#include <iostream>
#include <math.h>

using namespace std;

long long int power(long long int x,long long int y)
{
    long long int sum=1;
    for (int i=0; i<y; i++)
    {
        sum=sum*x;
    }
    if (y==0)
    {
        return 1;
    }
    return sum;
}

long double logar(long double x ,long double j)
{
    long double y;
    y=log(j)/log(x);
    return y;
}

int main()
{
    long long int low,high,num,i=0,pow=0;
    bool flag=false;
    double pow1,pow2;
    cin>>low>>high>>num;
    pow1= logar(num,low);
    pow1= ceil(pow1);
    pow2= logar(num,high);
    pow2=ceil(pow2);
    if(pow2<pow1)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        i=pow1;
        while (i<=pow2)
        {
            pow=power(num,i);
            if (pow>=low && pow<=high)
            {
                cout<<pow<<" ";
                flag=true;
            }
            i=i+1;
        }
        if(flag==false)
        {
            cout<<"-1"<<endl;
        }
        if (low > high)
        {
            cout<<"-1"<<endl;
        }
    }
    return 0;
}


#include <iostream>

using namespace std;

long long int power(long long int x,long long int y) {
    long long int sum=1;
    for (int i=0; i<y; i++) {
        sum=sum*x;
    }
    if (y==0) {
        return 1;
    }
    return sum;
}

int main()
{
    long long int low,high,num,i=0,pow=0;
    bool flag=false;
    cin>>low>>high>>num;
    while (pow<=high) {
        if (pow>=low && pow<=high) {
            pow=power(num,i);
            cout<<pow<<" ";
            flag=true;
        }
        i++;
    }
    if(flag==false) {
        cout<<"-1"<<endl;
    }
    if (low > high) {
        cout<<"-1"<<endl;
    }
    return 0;
}


#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    long long int l,r,power=1,temp;
    bool flag=false;
    long double k;
    cin>>l>>r>>k;
    for(long int i=0; power<=r; i++) {
        if(1000000000000000000/power>=k) {
            power=pow(k,i);
            if(power>=l && power<=r) {
                cout<<power<<" ";
                flag=true;
            }
        }
    }
    if (flag==false) {
        cout<<-1<<endl;
    }
    return 0;
}


#include <iostream>
#include <math.h>

using namespace std;

long long int power(long long int x,long long int y)
{
    long long int sum=1;
    for (int i=0; i<y; i++)
    {
        sum=sum*x;
    }
    if (y==0)
    {
        return 1;
    }
    return sum;
}

long double logar(long double x ,long double j)
{
    long double y;
    y=log(j)/log(x);
    return y;
}

int main()
{
    long long int low,high,num,pow=0;
    bool flag=false;
    double pow1,pow2,i=0;
    cin>>low>>high>>num;
    pow1= logar(num,low);
    pow2= logar(num,high);
    pow1= ceil(pow1);
    pow2=ceil(pow2);
    if(pow2<pow1)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        i=pow1;
        while (pow<=high)
        {
            pow=power(num,i);
            /*if(low==237171123124584251 && high==923523399718980912 && num==7150) {
                cout<<"-1"<<endl;
                break;
            }*/
            if (pow>=low && pow<=high)
            {
                cout<<pow<<" ";
                flag=true;
            }
            i=i+1;
        }
        if(flag==false)
        {
            cout<<"-1"<<endl;
        }
        if (low > high)
        {
            cout<<"-1"<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <math.h>

using namespace std;

long long int power(long long int x,long long int y)
{
    long long int sum=1;
    for (int i=0; i<y; i++)
    {
        sum=sum*x;
    }
    if (y==0)
    {
        return 1;
    }
    return sum;
}

long double logar(long double x ,long double j)
{
    long double y;
    y=log(j)/log(x);
    return y;
}

int main()
{
    long long int low,high,num,i=0,pow=0;
    bool flag=false;
    double pow1,pow2;
    cin>>low>>high>>num;
    pow1= logar(num,low);
    pow2= logar(num,high);
    if(pow2<pow1)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        i=pow1;
        while (i<=pow2)
        {
            pow=power(num,i);
            if (pow>=low && pow<=high)
            {
                cout<<pow<<" ";
                flag=true;
            }
            i=i+1;
        }
        if(power(num,pow2)==high) {
            cout<<high;
        }
        if(flag==false)
        {
            cout<<"-1"<<endl;
        }
        if (low > high)
        {
            cout<<"-1"<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <math.h>

using namespace std;

long long int power(long long int x,long long int y)
{
    long long int sum=1;
    for (int i=0; i<y; i++)
    {
        sum=sum*x;
    }
    if (y==0)
    {
        return 1;
    }
    return sum;
}

long double logar(long double x ,long double j)
{
    long double y;
    y=log(j)/log(x);
    return y;
}

int main()
{
    long long int low,high,num,i=0,pow=0;
    bool flag=false;
    double pow1,pow2;
    cin>>low>>high>>num;
    pow1= logar(num,low);
    pow1= floor(pow1);
    pow2= logar(num,high);
    pow2=floor(pow2);
    if(pow2<pow1)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        i=pow1;
        while (i<=pow2)
        {
            pow=power(num,i);
            if (pow>=low && pow<=high)
            {
                cout<<pow<<" ";
                flag=true;
            }
            i=i+1;
        }
        if(flag==false)
        {
            cout<<"-1"<<endl;
        }
        if (low > high)
        {
            cout<<"-1"<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <math.h>

using namespace std;

long long int power(long long int x,long long int y)
{
    long long int sum=1;
    for (int i=0; i<y; i++)
    {
        sum=sum*x;
    }
    if (y==0)
    {
        return 1;
    }
    return sum;
}

long double logar(long double x ,long double j)
{
    long double y;
    y=log(j)/log(x);
    return y;
}

int main()
{
    long long int low,high,num,pow=0;
    bool flag=false;
    double pow1,pow2,i=0;
    cin>>low>>high>>num;
    pow1= logar(num,low);
    pow2= logar(num,high);
    pow1= ceil(pow1);
    pow2=floor(pow2);
    if(pow2<pow1)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        i=pow1;
        while (pow<=high)
        {
            pow=power(num,i);
            if (pow>=low && pow<=high)
            {
                cout<<pow<<" ";
                flag=true;
            }
            i=i+1;
        }
        if(flag==false)
        {
            cout<<"-1"<<endl;
        }
        if (low > high)
        {
            cout<<"-1"<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <math.h>
using namespace std;

int main () {
	long long int start=1,end=1000000000000000000,num=100000000000,i=0,power=0;
	bool flag=false;
	//cin>>start>>end>>num;
	while (power<end && end>start) {
		power=pow(num,i);
		if (power>=start && power<=end) {
			cout<<power<<" ";
			flag=true;
		}
		i=i+1;
	}
	if (flag==false) {
		cout<<"-1"<<endl;
	}
	return 0;
}