### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

road = {}
train = {}
node_seen = set()
road_belong_group = {}
train_belong_group = {}
road_group = {}
train_group = {}
group_num_road = 0
group_num_train = 0
city_without_road = set()

def dfs_road(t_node):
    global road_group, road_belong_group, node_seen
    road_belong_group[t_node] = group_num_road
    road_group[group_num_road].add(t_node)
    node_seen.add(t_node)
    next_nodes = set(road[t_node]) - node_seen
    if len(next_nodes) == 0:
        return
    else:
        for nextnr in next_nodes:
            dfs_road(nextnr)

def dfs_train(t_node):
    global node_seen, train_group, train_belong_group
    train_belong_group[t_node] = group_num_train
    train_group[group_num_train].add(t_node)
    node_seen.add(t_node)
    next_nodes = set(train[t_node]) - node_seen
    if len(next_nodes) == 0:
        return
    else:
        for nextnt in next_nodes:
            dfs_train(nextnt)


def main():
    global road, train, node_seen, road_group, train_group, node_all, road_belong_group,train_belong_group, group_num_road, group_num_train, city_without_road
    # 入力
    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)}
    train = {e: [] for e in range(1, n + 1)}
    road_belong_group = {e: -1 for e in range(1, n + 1)}
    train_belong_group = {e: -1 for e in range(1, n + 1)}

    for _ in range(k):
        p, q = map(int, input().split())
        road[p].append(q)
        road[q].append(p)

    for _ in range(l):
        s, t = map(int, input().split())
        train[s].append(t)
        train[t].append(s)

    # 処理
    ## 道路

    group_num_road = 1
    for i_road in range(1, n + 1):
        if road_belong_group[i_road] != -1:
            continue
        if not road[i_road]:
            continue
        road_group[group_num_road] = set()
        dfs_road(i_road)
        group_num_road += 1
    city_without_road = set([ci for ci in road_belong_group if road_belong_group[ci] == -1])

    ## 鉄道
    node_seen = set([])
    group_num_train = 1
    for i_train in range(1, n + 1):
        if train_belong_group[i_train] != -1 or road_belong_group[i_train] == -1:
            continue
        if not train[i_train]:
            continue
        train_group[group_num_train] = set()
        dfs_train(i_train)
        group_num_train += 1

    # 出力
    for i in range(1, n + 1):
        rg = road_belong_group[i]
        tg = train_belong_group[i]
        if rg == -1 or tg == -1:
            print(1, end= ' ')
        else:
            linked_city = len(road_group[rg].intersection(train_group[tg]))
            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()