It's just a big complicated nucleophilic substitution reaction...
Ammonia will attack the carbon of one of the C-Br bonds with its lone pair, and so it'll replace Br with NH2
However, this NH2 group can do exactly the same thing with the other C-Br bond
If you follow it through -- you don't even need to complete the mechanism -- you'll see that the answer has to be D in order to produce coniine this way