I don't think I would try this one myself , I would find a licensed electrician to this work junction boxes can be trickery and if your asking this question for your own junction box I would venture to say play it safe and call an electrician or a local handyman that is certified for this kind of work that can also give you a guarantee of his work if something should go wrong afterwards.
This one is easy, if you stay methodical. I use a process of elimination as I wire. First, connect all the grounds together and wire nut them. Next, connect all the white wires together, except the white wire from the 3-way (C) and wire nut them. Now for the good stuff, take the black from power in (A) and connect to power out (D), and add the white wire from the 3-way (C), and wire nut them. Lastly, connect black wire from 3-way (C) to the black wire from the ceiling fan, and wire nut together.