import sys
input = sys.stdin.readline
large_p = 10**9 + 7

road = {}
train = {}
node_all = set()
node_seen = set()
road_belong_group = []
train_belong_group = []
road_group = {}
train_group = {}

def dfs_road(t_node, group_num):
    global node_seen, road_group, road_belong_group
    node_seen.add(t_node)
    road_belong_group[t_node] = group_num
    road_group[group_num].add(t_node)
    next_nodes = set(road[t_node]) - node_seen
    if not list(next_nodes):
        return
    else:
        for next in next_nodes:
            dfs_road(next, group_num)

def dfs_train(t_node, group_num):
    global node_seen, train_group, train_belong_group
    node_seen.add(t_node)
    train_belong_group[t_node] = group_num
    train_group[group_num].add(t_node)
    next_nodes = set(train[t_node]) - node_seen
    if not list(next_nodes):
        return
    else:
        for next in next_nodes:
            dfs_train(next, group_num)

def main():
    global road, train, node_seen, road_group, train_group, node_all, road_belong_group,train_belong_group
    # 入力
    n, k, l = map(int, input().split())
    node_all = set([i for i in range(1, n + 1)])
    road = {e:[] for e in range(1, n + 1)}
    road_belong_group = [0] * (n + 1)
    train_belong_group = [0] * (n + 1)
    road_belong_group[0] = -1
    train_belong_group[0] = -1

    for _ in range(k):
        p, q = map(int, input().split())
        road[p].append(q)
        road[q].append(p)
    train = {e:[] for e in range(1, n + 1)}
    for _ in range(l):
        s, t = map(int, input().split())
        train[s].append(t)
        train[t].append(s)

    # 処理
    ## 道路
    road_group[-1] = set()
    train_group[-1] = set()

    group_num_road = 1
    while list(node_all - node_seen):
        node_remain = road_belong_group.index(0)
        if node_remain == 0:
            node_remain = 1
        if not road[node_remain]:
            road_belong_group[node_remain] = -1
            node_seen.add(node_remain)
            continue
        road_group[group_num_road] = set()
        dfs_road(node_remain, group_num_road)
        group_num_road += 1


    ## 鉄道
    group_num_train = 1
    node_seen = set()
    while list(node_all - node_seen):
        node_remain = train_belong_group.index(0)
        if node_remain == 0:
            node_remain = 1
        if not train[node_remain]:
            train_belong_group[node_remain] = -1
            node_seen.add(node_remain)
            continue
        train_group[group_num_train] = set()
        dfs_train(node_remain, group_num_train)
        group_num_train += 1

    # 出力
    for i in range(1, n + 1):
        linked_city = len(road_group[road_belong_group[i]] & train_group[train_belong_group[i]] )
        if linked_city == 0:
            linked_city += 1
        print(linked_city, end = ' ')


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    def unite(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True
    def members(x):
        root = find(x)
        return [i for i in range(n) if find(i) == root]

    def find2(x):
        if par2[x] < 0:
            return x
        else:
            par2[x] = find2(par2[x])
            return par2[x]
    def unite2(x, y):
        x = find2(x)
        y = find2(y)
        if x == y:
            return False
        else:
            if par2[x] > par2[y]:
                x, y = y, x
            par2[x] += par2[y]
            par2[y] = x
            return True
    def members2(x):
        root2 = find2(x)
        return [i for i in range(n) if find2(i) == root2]

    n, k, l = map(int, input().split())
    par = [-1] * n
    par2 = [-1] * n
    for _ in range(k):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        unite(a, b)
    for _ in range(l):
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        unite2(c, d)

    root_pairs = defaultdict(int)
    for i in range(n):
        root_pairs[find(i), find2(i)] += 1

    for i in range(n):
        print(root_pairs[find(i), find2(i)], end=' ')

if __name__ == '__main__':
    main()