The one with four studs goes to the manifold... It's the inlet.. the valve inside there moves upwards towards the allyo section and release gas through the outlet pipe...
It should bolt straight onto the manifold... if you haven't got it then the exhaust shop making it will know anyways...
I think you may be referring to the bleed pipes... you'll need to consult your setup drawing for the boost controller to work this out.. it depends how they work... more then likely you will jsut connect the bottom one up... IE not in the end of the gate... This will open the gate when boost is put through it...
If you have a good electronic valve you can connect it using both lines... I won't go into the basics behind this now, but you need to feed boost to both pipes, and have the three port solenoid inline with the top pipe this time...
When solenoid isn't activated the boost should be seen on both pipe, but when it is activated it should vent the top gate pipe to atmosphere.. opening the gate...