#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

const int maxn = 2e5+10;

int froad[maxn];
int frailway[maxn];
//int fsum[maxn];
int num[maxn];
int head[maxn];
int nex[maxn];
int cnt[maxn];
int t[maxn];
/*

typedef struct CITY
{
    int roadnum;
    int railwaynum;
    vector <int> road;
    vector <int> railways;
}City;

City a[maxn];
//
bool hasroad[maxn];
bool hasrailway[maxn];

void getroad(int x)
{
    memset(hasroad,false;n*sizeof(bool));
    for(int i=0;i<a[i].roadnum;i++)
    {
        vector <int> :: iterator it;
        for(it=a[i].road.begin();it!=a[i]road.end();it++)
        {
            if(!hasroad[*it])
            {
                hasroad[*it]==true;
                getroad(*it);
            }
        }
    }
    return;
}

void getrailway(int x)
{
    memset(hasrailway,false;n*sizeof(bool));
    for(int i=0;i<a[i].railwaynum;i++)
    {
        vector <int> :: iterator it;
        for(it=a[i].railway.begin();it!=a[i]railway.end();it++)
        {
            if(!hasrailway[*it])
            {
                hasrailway[*it]==true;
                getrailway(*it);
            }
        }
    }
    return;
}
*/

int getfather(int p,int f[])
{
	if(p!=f[p])
		f[p]=getfather(f[p],f);
	return f[p];
}

int main()
{
    int n,k,l;
    scanf("%d%d%d",&n,&k,&l);
    for(int i=1;i<=n;i++)
    {
        froad[i]=i;
        frailway[i]=i;
//        fsum[i]=i;
        num[i]=0;
        head[i]=0;
        nex[i]=0;
        t[i]=0;
    /*    a[i].roadnum=0;
        a[i].railwaynum=0;
        a[i].road.clear();
        a[i].railways.clear();*/
    }
    for(int i=0;i<k;i++)
    {
        int p,q;
        scanf("%d%d",&p,&q);
        int pf=getfather(p,froad);
        int qf=getfather(q,froad);
        if(pf!=qf)
        {
            if(qf<pf)
                froad[pf]=qf;
            else
                froad[qf]=pf;
        }
      //  a[p].road.push_back(q);
      // a[p].roadnum++;
      //  a[q].road.push_back(p);
      //  a[q].roadnum++;
    }
     for(int i=0;i<l;i++)
    {
        int p,q;
        scanf("%d%d",&p,&q);
        int pf=getfather(p,frailway);
        int qf=getfather(q,frailway);
       // int pf0=getfather(p,froad);
       // int qf0=getfather(q,froad);
        if(pf!=qf)
        {
            if(qf<pf)
                frailway[pf]=qf;
            else
                frailway[qf]=pf;

           /* if(pf0==qf0)
            {
                int pfs=getfather(p,fsum);
                int qfs=getfather(q,fsum);
                if(pfs!=qfs)
                {
                    if(qfs<pfs)
                    {
                        fsum[pfs]=qfs;
                        num[qfs]=num[qfs]+num[pfs];
                    }
                    else
                    {
                        fsum[qfs]=pfs;
                        num[pfs]=num[qfs]+num[pfs];
                    }
                }
            }*/
        }
       /* a[p].railway.push_back(q);
        a[p].railwaynum++;
        a[q].railways.push_back(p);
        a[q].railwaynum++;*/
    }
    for(int i=1;i<=n;i++)
    {
        int tempf=getfather(i,froad);
        if(tempf==i)
            head[i]=i;
        else
        {
            nex[i]=head[tempf];
            head[tempf]=i;
        }
    }
    int ct=0;
    for(int i=1;i<=n;i++)
    {
        if(head[i]>0)
        {
            ct++;
            //memset(cnt,0,n*sizeof(int));
            for(int j=head[i];j>0;j=nex[j])
            {
                int tempf=getfather(j,frailway);
                if(t[tempf]==ct)
                    cnt[tempf]++;
                else
                {
                    t[tempf]=ct;
                    cnt[tempf]=1;
                }
            }
            for(int j=head[i];j>0;j=nex[j])
            {
                int tempf=getfather(j,frailway);
                num[j]=cnt[tempf];
            }
        }
    }
    for(int i=1;i<=n-1;i++)
    {
    /*    int temp=getfather(i,fsum);
        int sum=num[temp];*/
        printf("%d ",/*sum*/num[i]);
    }
 /*   int temp=getfather(n,fsum);
    int sum=num[temp];
    printf("%d\n",sum);*/
    printf("%d\n",num[n]);
    return 0;
}


Measured memory_bytes: 6144