Mechanism of nucleophilic substitution in palladium(II) complexes of terpyridine