using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, K, L) = Slice3<long>();

            var pqGraph = new long[N].Select(_ => new List<long>()).ToArray();
            for (var i = 0; i < K; ++i)
            {
                var (p, q) = Slice2<long>();
                --p; --q;
                pqGraph[p].Add(q); pqGraph[q].Add(p);
            }
            var rsGraph = new long[N].Select(_ => new List<long>()).ToArray();
            for (var i = 0; i < L; ++i)
            {
                var (r, s) = Slice2<long>();
                --r; --s;
                rsGraph[r].Add(s); rsGraph[s].Add(r);
            }
            var pqGroup = Enumerable.Repeat(-1L, (int)N).ToArray();
            for (var i = 0; i < N; ++i)
            {
                if (pqGroup[i] != -1) continue;
                pqGroup[i] = i;
                dfs(i, pqGraph, pqGroup);
            }
            var rsGroup = Enumerable.Repeat(-1L, (int)N).ToArray();
            for (var i = 0; i < N; ++i)
            {
                if (rsGroup[i] != -1) continue;
                rsGroup[i] = i;
                dfs(i, rsGraph, rsGroup);
            }
            var dct = new Dictionary<(long pq, long rs), long>();
            for (var i = 0; i < N; ++i)
            {
                var tpl = (pqGroup[i], rsGroup[i]);
                if (!dct.ContainsKey(tpl)) dct[tpl] = 0;
                ++dct[tpl];
            }
            var ans = new long[N];
            for (var i = 0; i < N; ++i)
            {
                var tpl = (pqGroup[i], rsGroup[i]);
                ans[i] = dct[tpl];
            }
            WriteLine(string.Join(" ", ans));
        }
        static void dfs(long root, List<long>[] graph, long[] group)
        {
            foreach (var v in graph[root])
            {
                if (-1 != group[v]) continue;
                group[v] = group[root];
                dfs(v, graph, group);
            }
        }
 
        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 89604