2006 Subaru Outback rough idle and stalling

I will find out the numbers. So what is the difference or how to you tell if it is the seals at the intake manifold or the head gasket. Is there a difference?