#!/usr/bin/env fsharpi

open System;

let readIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let readInt1 ( str : string ) =
    readIntN str |> fun arr -> arr.[0]

let readInt2 ( str : string ) =
    readIntN str |> fun arr -> (arr.[0],arr.[1])

let readInt3 ( str : string ) =
    readIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])


type UnionFind (N) =
    let id : int[] = Array.init N (fun i -> i )
    let sz : int[] = Array.create N 1

    member t.root i =
        let mutable q = i
        while ( q <> id.[q] ) do
            id.[q] <- id.[id.[q]]
            q <- id.[q]
        q

    member t.find( p, q ) =
        t.root(p) = t.root(q)

    member t.unite( p, q ) =
        let i = t.root( p )
        let j = t.root( q )
        if sz.[i] < sz.[j] then id.[i] <- j; sz.[j] <- sz.[j] + sz.[i]
        else id.[j] <- i; sz.[i] <- sz.[i] + sz.[j]

let (n,k,l) = readInt3 <| Console.ReadLine()

let rail = UnionFind (n+1)
for i = 1 to k do
    let (p,q) = readInt2 <| Console.ReadLine()
    rail.unite( p, q )
done

let road = UnionFind (n+1)
for i = 1 to l do
    let (p,q) = readInt2 <| Console.ReadLine()
    road.unite( p, q )
done

let rail_sets : Set<int>[] = Array.create (n+1) (set [])
let road_sets : Set<int>[] = Array.create (n+1) (set [])
for i = 1 to n do
    let rail_i = rail.root i
    rail_sets.[rail_i] <- Set.add i rail_sets.[rail_i]

    let road_i = road.root i
    road_sets.[road_i] <- Set.add i road_sets.[road_i]
done

let mutable cnt_map : Map< int * int, int > = Map.empty
for i = 1 to n do
    let root_tuple = ( (rail.root i), (road.root i) )
    cnt_map <- if Map.containsKey root_tuple cnt_map then (Map.add root_tuple ( ( Map.find root_tuple cnt_map ) + 1 ) cnt_map) else (Map.add root_tuple 1 cnt_map)
done

for i = 1 to n do
    let rail_i = rail.root i
    let road_i = road.root i
    let root_tuple = ( rail_i, road_i )
    let cnt = Map.find root_tuple cnt_map
    Console.Write( cnt )
    if i <> n then
        Console.Write( ' ' )
    else
        Console.Write( '\n' )
done
