using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int K = cin.nextInt();
        int L = cin.nextInt();

        var dictRoad = new Dictionary<int, List<int>>();
        var dictRail = new Dictionary<int, List<int>>();

        for(int i = 0;i<N;i++)
        {
            dictRoad.Add(i, new List<int>());
            dictRail.Add(i, new List<int>());
        }
           
        for (int k = 0; k < K; k++)
        {
            int p = cin.nextInt() - 1;
            int q = cin.nextInt() - 1;
            dictRoad[p].Add(q);
            dictRoad[q].Add(p);
        }

        
        for (int l = 0; l < L; l++)
        {
            int r = cin.nextInt()-1;
            int s = cin.nextInt()-1;
            dictRail[r].Add(s);
            dictRail[s].Add(r);
        }

        //dictRoad-- < 頂点,連結頂点のリスト > のDict
        //cityColorRoad-- 各頂点の色を表すリスト
        int[] cityColorRoad = new int[N];
        int[] cityColorRail = new int[N];

        int colorRoad = 0;
        int colorRail = 0;
        for (int i = 0; i < N; i++)
        {
            if (cityColorRoad[i] == 0)
            {
                colorRoad++;
                cityColorRoad[i] = colorRoad;
                Paint(i, colorRoad, dictRoad, cityColorRoad);
            }
        }

        for (int i = 0; i < N; i++)
        {
            if (cityColorRail[i] == 0)
            {
                colorRail++;
                cityColorRail[i] = colorRail;
                Paint(i, colorRail, dictRail, cityColorRail);
            }
        }

        long[] cityColorAll = new long[N];
        for(int i = 0;i<N;i++)
        {
            cityColorAll[i] = (long)cityColorRail[i] * 1000000 + (long)cityColorRoad[i];
        }

        var dictColorAll = new Dictionary<long, List<int>>();
        for(int i = 0;i<N;i++)
        {
            var c = cityColorAll[i];
            if (!dictColorAll.ContainsKey(c)) dictColorAll.Add(c, new List<int>());
            dictColorAll[c].Add(i);
        }

        int[] cityRet = new int[N];
        var keys = dictColorAll.Keys.ToList();
        for(int i = 0;i<keys.Count;i++)
        {
            var key = keys[i];
            var list = dictColorAll[key];
            for(int j = 0;j<list.Count;j++)
            {
                cityRet[list[j]] = list.Count;
            }
        }

        Console.WriteLine(string.Join(" ", cityRet));
        Console.Read();

    }

    //グラフの連結成分の塗り分け
    public void Paint(int i, int color, Dictionary<int, List<int>> dict, int[] cityColors)
    {
        List<int> list = dict[i];
        for (int j = 0; j < list.Count; j++)
        {
            int city = list[j];
            if (cityColors[city] == 0)
            {
                cityColors[city] = color;
                Paint(city, color, dict, cityColors);
            }
        }
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 93084