local n, k, l = io.read("*n", "*n", "*n")

local function uf_initialize(n)
  local parent = {}
  for i = 1, n do parent[i] = i end
  return parent
end

local function uf_findroot(idx, parent)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end

local p1 = uf_initialize(n)
for i = 1, k do
  local p, q = io.read("*n", "*n")
  local pr, qr = uf_findroot(p, p1), uf_findroot(q, p1)
  p1[qr], p1[q] = pr, pr
end

local p2 = uf_initialize(n)
for i = 1, l do
  local r, s = io.read("*n", "*n")
  local rr, sr = uf_findroot(r, p2), uf_findroot(s, p2)
  p2[sr], p2[s] = rr, rr
end

local group = {}
for i = 1, n do
  local r1, r2 = uf_findroot(i, p1), uf_findroot(i, p2)
  if not group[r1] then group[r1] = {} end
  if not group[r1][r2] then
    group[r1][r2] = 1
  else
    group[r1][r2] = group[r1][r2] + 1
  end
end
for i = 1, n do
  local r1, r2 = uf_findroot(i, p1), uf_findroot(i, p2)
  io.write(group[r1][r2])
  io.write(i == n and "\n" or " ")
end
