The Petersson/Kuznetsov trace formula with prescribed local ramifications