Simultaneous String Surgery

You are given a string s and three equally sized arrays. Entry i proposes a rewrite at position indices[i]: replace sources[i] with targets[i] only when sources[i] exactly matches the substring beginning there.

All proposals refer to positions in the original string. Apply every accepted rewrite simultaneously, so one replacement cannot move or invalidate another proposal. Proposal positions are distinct.

Return the resulting string. A proposal whose source does not match is ignored.

Examples
Input: ["mango",[0,3],["man","go"],["tea","pie"]]
Output: "teapie"
Hints
Related Problems

Simultaneous String Surgery

You are given a string `s` and three equally sized arrays. Entry `i` proposes a rewrite at position `indices[i]`: replace `sources[i]` with `targets[i]` only when `sources[i]` exactly matches the substring beginning there.