#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <sstream>
#include <time.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define lson l,m,rt*2
#define rson m+1,r,rt*2+1
#define mt(A,B) memset(A,B,sizeof(A))
using namespace std;
typedef long long LL;
//const double PI = acos(-1);
const int N=1e6+10;
const LL mod=1e9+7;
const int inf = 0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3fLL;
map<pair<int,int>,int> Q;
int pre[N],pra[N];
void init()
{
    for(int i=1;i<N;i++)
    {
        pre[i]=i;
        pra[i]=i;
    }
}
int found1(int x)
{
    if(pre[x]==x)return x;
    else return pre[x]=found1(pre[x]);
}
int found2(int x)
{
    if(pra[x]==x)return x;
    else return pra[x]=found2(pra[x]);
}
void unite1(int x,int y)
{
    int fx=found1(x);
    int fy=found1(y);
    if(fx!=fy)pre[fx]=fy;
}
void unite2(int x,int y)
{
    int fx=found2(x);
    int fy=found2(y);
    if(fx!=fy)pra[fx]=fy;
}
int main()
{
#ifdef Local
    freopen("data.txt","r",stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int u,v,n,k,l;
    cin>>n>>k>>l;
    init();
    for(int i=0;i<k;i++)
    {
        cin>>u>>v;
        unite1(u,v);
    }
    for(int i=0;i<l;i++)
    {
        cin>>u>>v;
        unite2(u,v);
    }
    for(int i=1;i<=n;i++)
    {
        Q[mp(found1(i),found2(i))]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(i==n)cout<<Q[mp(found1(i),found2(i))]<<endl;
        else cout<<Q[mp(found1(i),found2(i))]<<" ";
    }
#ifdef Local
    cerr << "time: " << (LL) clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
}
