using System;
using System.Text;
using System.Collections.Generic;

class Program
{
    const int MOD = (int)1e9 + 7;
    const int INT_MAX = 2147483647;
    static void Main(string[] args)
    {
        int[] nkl = Scan.IntArray(3);
        int n, k, l;
        n = nkl[0]; k = nkl[1]; l = nkl[2];
        UnionFind ufroad = new UnionFind();
        UnionFind ufrail = new UnionFind();
        ufroad.Init(n);
        ufrail.Init(n);
        for (int i = 0; i < k; i++)
        {
            int[] pq = Scan.IntArray(2);
            ufroad.Unite(pq[0] - 1, pq[1] - 1, 0);
        }
        for (int i = 0; i < l; i++)
        {
            int[] rs = Scan.IntArray(2);
            ufrail.Unite(rs[0] - 1, rs[1] - 1, 0);
        }
        int[] road = new int[n];
        int[] rail = new int[n];
        for (int i = 0; i < n; i++)
        {
            road[i] = ufroad.Root(i);
            rail[i] = ufrail.Root(i);
        }
        Dictionary<Tuple<int, int>, int> dic = new Dictionary<Tuple<int, int>, int>();
        for (int i = 0; i < n; i++)
        {
            Tuple<int, int> t = new Tuple<int, int>(road[i], rail[i]);
            if (dic.ContainsKey(t))
            {
                dic[t]++;
            }
            else
            {
                dic.Add(t, 1);
            }
        }
        int[] res = new int[n];
        for (int i = 0; i < n; i++)
        {
            Tuple<int, int> tt = new Tuple<int, int>(road[i], rail[i]);
            res[i] = dic[tt];
        }
        Out.Array(res);
    }
}

public class Scan
{
    public static int[] IntArray(int t)
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] ar = new int[t];
        for (int i = 0; i < t; i++)
        {
            ar[i] = int.Parse(str[i]);
        }
        return ar;
    }
}

public class Out
{
    public static void Array<T>(T[] a)
    {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < a.Length; i++)
        {
            sb.Append(a[i]);
            if(i != a.Length - 1)
            {
                sb.Append(" ");
            }
        }
        string s = sb.ToString();
        Console.WriteLine(s);
    }
}
    
public class UnionFind
{
    public int[] parent;
    public int[] rank;
    public long[] weightDiff;

    public void Init(int size)
    {
        parent = new int[size + 5];
        rank = new int[size + 5];
        weightDiff = new long[size + 5];
        for (int i = 0; i < size; i++)
        {
            parent[i] = i;
            rank[i] = 0;
            weightDiff[i] = 0;
        }
    }

    public int Root(int x)
    {
        if (parent[x] == x)
        {
            return x;
        }
        else
        {
            int r = Root(parent[x]);
            weightDiff[x] += weightDiff[parent[x]];
            return parent[x] = r;
        }
    }

    public bool Unite(int x, int y, long w) // Add edge x <- y (weight: w)
    {
        w = w + GetWeight(x) - GetWeight(y);
        x = Root(x);
        y = Root(y);
        if (x == y) return false;
        if (rank[x] < rank[y])
        {
            int tmp = x; x = y; y = tmp;
            w *= -1;
        }
        if (rank[x] == rank[y])
        {
            ++rank[x];
        }
        parent[y] = x;
        weightDiff[y] = w;
        return true;
    }

    public bool Same(int x, int y)
    {
        return Root(x) == Root(y);
    }

    public long GetWeight(int x)
    {
        Root(x);
        return weightDiff[x];
    }

    public long Diff(int x, int y) // x -> y
    {
        return GetWeight(y) - GetWeight(x);
    }
}

Measured memory_bytes: 45088