Look up “double marginalisation”.