fun main(args: Array<String>) {
    val (n,k,l)= readLine()!!.split(" ").map { it.toInt() }
    val road=Array(n){ mutableListOf<Int>() }
    val rail=Array(n){ mutableListOf<Int>() }
    (1..k).forEach {
        val pq = readLine()!!.split(" ").map { it.toInt()-1 }
        road[pq[0]].add(pq[1])
        road[pq[1]].add(pq[0])
    }
    (1..l).forEach {
        val rs = readLine()!!.split(" ").map { it.toInt()-1 }
        rail[rs[0]].add(rs[1])
        rail[rs[1]].add(rs[0])
    }

    val visitK=IntArray(n){-1}
    val visitL=IntArray(n){-1}
    for(i in 0..n-1){
        dfs(i,i,road,visitK)
    }
    for(i in 0..n-1){
        dfs(i,i,rail,visitL)
    }
    val map = (0..n-1).map { visitK[it]*n.toLong()+visitL[it] }.groupBy { it }.mapValues { it.value.size }
    val ans = (0..n-1).map { map[visitK[it]*n.toLong()+visitL[it]] }.joinToString(" ")
    println(ans)
}

fun dfs(v: Int, root: Int, adj: Array<MutableList<Int>>, visit: IntArray){
    if(visit[v]!=-1) return
    visit[v]=root
    adj[v].forEach {
        dfs(it,root,adj,visit)
    }
}