#include <bits/stdc++.h>

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a,b,c,cmp,cmpp,m,h,w,k,l,x,y,sum=0,pos,par[1000000],par2[1000000],ran[1000000],ran2[1000000];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

long long int root(long long int xx){
    if(par[xx]==xx){
        return xx;
    }
    else{
        return par[xx]=root(par[xx]);
    }
}
 
 
bool same(long long int xx,long long int yy){
    return root(xx)==root(yy);
}
 
void unite(long long int xx,long long int yy){
    xx=root(xx);
    yy=root(yy);
    if(xx==yy)return;
    
    if(ran[xx]<ran[yy]){
        par[xx]=yy;
    }
    else{
        par[yy]=xx;
        if(ran[xx]==ran[yy])ran[xx]++;
    }
}
long long int root2(long long int xx){
    if(par2[xx]==xx){
        return xx;
    }
    else{
        return par2[xx]=root2(par2[xx]);
    }
}
 
 

 
void unite2(long long int xx,long long int yy){
    xx=root2(xx);
    yy=root2(yy);
    if(xx==yy)return;
    
    if(ran2[xx]<ran2[yy]){
        par2[xx]=yy;
    }
    else{
        par2[yy]=xx;
        if(ran2[xx]==ran2[yy])ran2[xx]++;
    }
}
int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);

     map<pair<int,int>,int> mp;
      cin >> n >> k >> l;
      rrep(i,1,n+1){
          par[i]=i;
          par2[i]=i;
      }
      rep(i,k){
          cin >> a >> b;
          unite(a,b);
         // Cout(a);
          //Cout(b);
      }
      rep(i,l){
          cin >> x >> y;
          unite2(x,y);
         // Cout(root(x));
          //Cout(root(y));
      }
      rrep(i,1,n+1){
          mp[{root(i),root2(i)}]++;
         // cout << mp[{root(i),root2(i)}] << " ";
      }
     // cout << endl;
      rrep(i,1,n+1){
          cout << mp[{root(i),root2(i)}] << " ";
      }
      cout << endl;
       
return 0;
}


Measured memory_bytes: 22400