Time-dependent amplitude analysis of B0 -> K0S pi+ pi-