// Slower C++ solution:
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;

typedef long long LL;

inline int read() {

	int f=1,x=0; char ch=getchar();

	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }

	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }

	return x*f;

}



const int MAXN=200005;

int n,m,r,tot,v[MAXN],f[MAXN],ans[MAXN];

struct List{

	int l,lt[MAXN],nt[MAXN<<1],v[MAXN<<1];

	void clear() { l=0; memset(lt,0,sizeof(lt)); }

	void addedge(int x,int y) { nt[++l]=lt[x]; lt[x]=l; v[l]=y; }

}E;

struct Data{

	int x,y;

	bool operator <(const Data &B)const { return x<B.x; }

}A[MAXN];

int ask(int x) { if (f[x]==x) return x; f[x]=ask(f[x]); return f[x]; }

void dfs(int x) {

	v[x]=1; A[++tot].x=ask(x); A[tot].y=x;

	for (int i=E.lt[x];i;i=E.nt[i]) if (!v[E.v[i]]) dfs(E.v[i]);

}

int main() {

	int i,j,k,l;

	n=read(); m=read(); r=read();

	for (i=1;i<=n;++i) f[i]=i; E.clear();

	for (i=1;i<=m;++i) {

		j=read(); k=read();

		E.addedge(j,k); E.addedge(k,j);

	}

	for (i=1;i<=r;++i) {

		j=ask(read()); k=ask(read());

		if (j!=k) f[j]=k;

	}

	memset(v,0,sizeof(v));

	for (i=1;i<=n;++i)

	if (!v[i]) {

		tot=0; dfs(i); sort(A+1,A+1+tot);

		for (j=1;j<=tot;j=k+1) {

			for (k=j;k<tot&&A[k+1].x==A[j].x;++k);

			for (l=j;l<=k;++l) ans[A[l].y]=k-j+1;

		}

	}

	for (i=1;i<n;++i) printf("%d ",ans[i]); printf("%d\n",ans[n]);

	return 0;

}



/*

4 3 1

1 2

2 3

3 4

2 3



*/


// Faster C++ solution for the same problem (measured speedup: 2.5250115949595853x):
#include <iostream>

#include <cstdio>

#include <vector>

#include <map>

#include <algorithm>

#include <cstring>

using namespace std;

typedef long long LL;

const int maxn = 4e5 + 8;



//有时可能需要 并查集+离散化





int father[maxn], _rank[maxn];

inline void DisjointSet(int n)

{

    for(int i = 0; i <= n; i++){

        father[i] = i;

        _rank[i] = 0;

    }

}



inline int _find(int v)

{

    return father[v] = father[v] == v ? v : _find(father[v]);

    //同时压缩路径，有时不能压缩路径，有时必须压缩路径，看具体情况

}



inline void _merge(int x, int y)

{

    int a = _find(x), b = _find(y);                //

    if(_rank[a] < _rank[b]){

        father[a] = b;

    }

    else{

        father[b] = a;

        if(_rank[a] == _rank[b]){

            _rank[a]++;

        }

    }

}





int father1[maxn], _rank1[maxn];

inline void DisjointSet1(int n)

{

    for(int i = 0; i <= n; i++){

        father1[i] = i;

        _rank1[i] = 0;

    }

}



inline int _find1(int v)

{

    return father1[v] = father1[v] == v ? v : _find1(father1[v]);

    //同时压缩路径，有时不能压缩路径，有时必须压缩路径，看具体情况

}



inline void _merge1(int x, int y)

{

    int a = _find1(x), b = _find1(y);                //

    if(_rank1[a] < _rank1[b]){

        father1[a] = b;

    }

    else{

        father1[b] = a;

        if(_rank1[a] == _rank1[b]){

            _rank1[a]++;

        }

    }

}





map<int, vector<int>> mp1, mp2;

map<int, int> cnt;

int ans[maxn];



int main()

{

    #ifdef LOCAL

    freopen("a.txt", "r", stdin);

    //freopen("a.out", "w", stdout);

    int T = 4;

    while(T--){

    #endif // LOCAL

    ios::sync_with_stdio(false); cin.tie(0);





    int n, p, q, u, v;

    cin >> n >> p >> q;

    DisjointSet(n), DisjointSet1(n);

    while(p--){

        cin >> u >> v;

        if(_find(u) != _find(v)) _merge(_find(u), _find(v));

    }



    while(q--){

        cin >> u >> v;

        if(_find1(u) != _find1(v)) _merge1(_find1(u), _find1(v));

    }



    for(int i = 1; i <= n; i++){

        mp1[_find(i)].push_back(i);

    }

    for(int i = 1; i <= n; i++){

        mp2[_find1(i)].push_back(i);

    }



    for(auto i = mp1.begin(); i != mp1.end(); i++){

        sort((i->second).begin(), (i->second).end());

    }

    for(auto i = mp2.begin(); i != mp2.end(); i++){

        sort((i->second).begin(), (i->second).end());

    }



    //cout << "?"<<endl;



    int i, j, a, b, pa, pb, sza, szb, l, r, mid;

    for(i = 1; i <= n; i++){

        if(ans[i] != 0) continue;

        pa = _find(i); pb = _find1(i);

        sza = mp1[pa].size(), szb = mp2[pb].size();

        cnt.clear();

        a = 0, b = 0;

        while(a < sza && b < szb){

            if(mp1[pa][a] == mp2[pb][b]){

                cnt[mp1[_find(i)][a]]++;

                a++;

                b++;

            }

            else if(mp1[pa][a] > mp2[pb][b]){

                if(b + 1== szb){

                    break;

                }

                else if(mp1[pa][a] > mp2[pb][szb - 1]){

                    break;

                }

                else{

                    l = b, r = szb;

                    b = szb - 1;

                    while(l + 1 < r){

                        mid = (l + r) >> 1;

                        if(mp1[pa][a] <= mp2[pb][mid]){

                            r = mid;

                            b = min(b, mid);

                        }

                        else l = mid;

                    }



                }

            }

            else{

                if(a + 1 == sza){

                    break;

                }

                else if(mp1[pa][sza - 1] < mp2[pb][b]){

                    break;

                }

                else{

                    l = a, r = sza;

                    a = sza - 1;

                    while(l + 1 < r){

                        mid = (l + r) >> 1;

                        if(mp1[pa][mid] >= mp2[pb][b]){

                            r = mid;

                            a = min(a, mid);

                        }

                        else l = mid;

                    }

                }

            }

        }

        sza = cnt.size();

        for(auto k = cnt.begin(); k != cnt.end(); k++){

            ans[k->first] = sza;

        }

    }



    for(i = 1; i <= n; i++){

        if(i == 1) cout << ans[i];

        else cout << " " << ans[i];

    }





    cout << endl;



    #ifdef LOCAL

    memset(ans, 0, sizeof ans);

    mp1.clear();

    mp2.clear();

    cout << endl;

    }

    #endif // LOCAL

    return 0;

}