XF 1.4 How to add code to first (and last) post on page?

Okay, everywhere I look for conditional help I find how to add code "after" the first post. What I need is a conditional for code to work/display INSIDE the first post of a page (and not only the first post of the discussion - but the post on top for each page in the discussion).

I'm in the "ad_message_body" template. Ultimately, I'd like to display an ad the top right of the first post on the page - and an ad to the top right of the LAST post on a page. Any assistance would be greatly appreciated...