using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair<T> { public T x, y; public Pair(T xx, T yy) { x = xx; y = yy; } }
    private static int[] dx = { 1, 0, -1, 0 };
    private static int[] dy = { 0, -1, 0, 1 };
    public static void Main()
    {
        int N = NextInt();
        int K = NextInt();
        int L = NextInt();
        UnionFind UF1 = new UnionFind(N);
        UnionFind UF2 = new UnionFind(N);
        for (int i = 0; i < K; i++)
        {
            int p = NextInt() - 1;
            int q = NextInt() - 1;
            UF1.Unite(p, q);
        }
        for (int i = 0; i < L; i++)
        {
            int r = NextInt() - 1;
            int s = NextInt() - 1;
            UF2.Unite(r, s);
        }
        int[] pw = new int[N];
        int[] pt = new int[N];
        for (int i = 0; i < N; i++)
        {
            pw[i] = UF1.Root(i);
            pt[i] = UF2.Root(i);
        }
        Dictionary<int, Dictionary<int, int>> dic = new Dictionary<int, Dictionary<int, int>>();
        for (int i = 0; i < N; i++)
        {
            if (!dic.ContainsKey(pw[i])) dic[pw[i]] = new Dictionary<int, int>();
            if (!dic[pw[i]].ContainsKey(pt[i])) dic[pw[i]][pt[i]] = 0;
            dic[pw[i]][pt[i]]++;
        }
        for (int i = 0; i < N; i++)
            Console.Write(dic[pw[i]][pt[i]] + " ");
        Console.WriteLine();
    }
}


public class UnionFind
{
    private List<int> parent = new List<int>();
    private void Swap(ref int a, ref int b) { int c = a; a = b; b = c; }

    public UnionFind(int N)
    {
        for (int i = 0; i < N; i++) { parent.Add(-1); }
    }

    public int Root(int a)
    {
        if (parent[a] < 0) return a;
        else return parent[a] = Root(parent[a]);
    }

    public void Unite(int a, int b)
    {
        a = Root(a);
        b = Root(b);
        if (a == b) return;
        if (parent[a] > parent[b]) Swap(ref a, ref b);
        parent[a] += parent[b];
        parent[b] = a;
    }

    public int Get(int a) { return -parent[Root(a)]; }

    public bool Same(int a, int b) { return (Root(a) == Root(b)); }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 74540