module mod1
implicit none
integer(8) :: par(200000),par2(200000),par_total(200000),num(200000),ans(200000)=0
end module mod1

program test
use mod1
implicit none
integer(8) :: n,i,j,k,l,last,kind
integer(8) :: p(100000),q(100000),r(100000),s(100000)

read(*,*) n,k,l
!道路
do i=1,k
	read(*,*) p(i),q(i)
enddo
!鉄道
do i=1,l
	read(*,*) r(i),s(i)
enddo

do i=1,n
	par(i) = i
	par2(i) = i
enddo

!道路
do i=1,k
	call unite(p(i),q(i))
enddo

!鉄道
do i=1,l
	call unite2(r(i),s(i))
enddo

do i=1,n
	num(i) = i
	par_total(i) = 1000000*par(i) + par2(i)
enddo

call heapsort2(n,par_total(1:n),num(1:n))

!種類を数える！
do i=1,n
	if(i==1) then
		last=1
		kind=1
	else if(par_total(i) .eq. par_total(i-1)) then 
		kind = kind + 1
	else
		do j = last,i-1
			ans(num(j)) = ans(num(j)) + kind
		enddo
		kind = 1
		last = i
	endif
	
	!最後の処理
	if(i==n) then
		do j = last,i
			ans(num(j)) = ans(num(j)) + kind
		enddo
	endif
enddo

write(*,*) ans(1:n)

contains
!道路
recursive function root(x) result(res)
integer(8) :: x,res
	if(par(x) == x) then
		continue
	else
		par(x) = root(par(x))
	endif
	res = par(x)
end function

subroutine unite(x,y)
integer(8) :: x,y
x = root(x)
y = root(y)
if(x > y) then
	par(x) = y
	par(y) = y
else if (x < y) then
	par(y) = x
	par(x) = x
endif
end subroutine


!鉄道
recursive function root2(x) result(res)
integer(8) :: x,res
	if(par2(x) == x) then
		continue
	else
		par2(x) = root2(par2(x))
	endif
	res = par2(x)
end function

subroutine unite2(x,y)
integer(8) :: x,y
x = root2(x)
y = root2(y)
if(x > y) then
	par(x) = y
	par(y) = y
else if (x < y) then
	par(y) = x
	par(x) = x
endif
end subroutine

subroutine heapsort2(n,y1,y2)

	implicit none
	integer(8),intent(in) :: n
	integer(8),intent(inout) :: y1(1:n)
	integer(8),intent(inout) :: y2(1:n)
	integer(8) :: i,k,j,l
	integer(8) :: t1,t2
	
	l = n/2+1
	k = n

	do while (k /= 1)
		 if(l > 1) then
				l = l-1
				t1 = y1(l)
				t2 = y2(l)
				
		 else
				t1 = y1(k)
				t2 = y2(k)
				y1(k) = y1(1)
				y2(k) = y2(1)
				k = k-1
				if(k == 1) then
					 y1(1) = t1
					 y2(1) = t2
					 exit
				endif
		 endif

		 i = l
		 j = l+l

		 do while(j <= k)
				if(j < k) then
					 if(y1(j) < y1(j+1)) j = j+1
				endif
				
				if (t1 < y1(j)) then
					 y1(i) = y1(j)
					 y2(i) = y2(j)
					 i = j
					 j = j+j
				else
					 j = k+1
				endif
		 
		 enddo
		 
		 y1(i) = t1
		 y2(i) = t2
	
	enddo
	return

end subroutine heapsort2

end program test