### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import deque

def main():
    # 入力
    n, k, l = map(int, input().split())
    road_a = [None] * k
    road_b = [None] * k
    road = [[] for _ in range(n + 1)]
    train_a = [None] * l
    train_b = [None] * l
    train = [[] for _ in range(n + 1)]
    city_group_in_road = {e: -1 for e in range(1, n + 1)}
    city_group_in_train = {e: -1 for e in range(1, n + 1)}
    road_groups = {}
    train_groups = {}
    stack_road = deque()
    stack_train = deque()

    for i1 in range(k):
        road_a[i1], road_b[i1] = map(int, input().split())
        road[road_a[i1]].append(road_b[i1])
        road[road_b[i1]].append(road_a[i1])
    for i2 in range(l):
        train_a[i2], train_b[i2] = map(int, input().split())
        train[train_a[i2]].append(train_b[i2])
        train[train_b[i2]].append(train_a[i2])

    # 処理
    ## 道路
    group_num_road = 1
    for i_road in range(1, n + 1):
        if city_group_in_road[i_road] == -1 and road[i_road] != []:
            road_groups[group_num_road] = set()
            road_groups[group_num_road].add(i_road)
            city_group_in_road[i_road] = group_num_road
            stack_road += road[i_road]
            while stack_road:
                next = stack_road.popleft()
                if city_group_in_road[next] != -1:
                    continue
                road_groups[group_num_road].add(next)
                city_group_in_road[next] = group_num_road
                stack_road += road[next]
            group_num_road += 1


    ## 鉄道
    group_num_train = 1
    for i_train in range(1, n + 1):
        if city_group_in_train[i_train] == -1 and train[i_train] != []:
            train_groups[group_num_train] = set()
            train_groups[group_num_train].add(i_train)
            city_group_in_train[i_train] = group_num_train
            stack_train += train[i_train]
            while stack_train:
                next = stack_train.popleft()
                if city_group_in_train[next] != -1:
                    continue
                train_groups[group_num_train].add(next)
                city_group_in_train[next] = group_num_train
                stack_train += train[next]
            group_num_train += 1

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