There are two containers connected to each other but separated by a cork. If container(1) has a gas $G_1$ at a volume $V_1$, pressure $P_1$ and temperature $T_1$ and similarly in container(2) there is a gas $G_2$ at volume $V_2$, pressure $P_2$ and temperature $T_2$. If the cork between the containers is removed and the temperature changed to $T_3$ what is the pressure of the mixture inside the system of containers.
My textbook gives it as:
$\frac{P_1V_1}{T_1}+\frac{P_2V_2}{T_2}=\frac{P_3V_3}{T_3}$
where $V_3$ = $V_1$+$V_2$
$P_3=\frac{T_3}{V_3}\left(\frac{P_1V_1}{T_1}+\frac{P_2V_2}{T_2}\right)$
I don't understand how that comes out. Can we just add the constants(of combined gas law) like that?