#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int fa[200005];
int fa1[200005];
int vis[200005];

int find1(int a)
{
    if(fa[a]!=a)
        fa[a]=find1(fa[a]);
    return fa[a];
}
void union1(int a,int b)
{
    fa[find1(a)]=find1(b);
}

int find2(int a)
{
    if(fa1[a]!=a)
        fa1[a]=find2(fa1[a]);
    return fa1[a];
}
void union2(int a,int b)
{
    fa1[find2(a)]=find2(b);
}
int main()
{
    int n,k,l;
    cin>>n>>k>>l;
    memset(vis,0,sizeof(vis));
    for(int i=0;i<=n;i++)
    {
        fa[i]=i;
        fa1[i]=i;
    }
    for(int i=0;i<k;i++)
    {
        int l1,r;
        scanf("%d %d",&l1,&r);
        union1(l1,r);
    }
    for(int i=0;i<l;i++)
    {
        int l1,r;
        scanf("%d %d",&l1,&r);
        if(find1(l1)==find1(r))
        union2(l1,r);
    }
    for(int i=1;i<=n;i++)
    {
        vis[find2(i)]++;
    }
    for(int i=1;i<=n;i++)
    cout <<vis[find2(i)]<<' ';
    cout<<endl;
    return 0;
}
