I don't have my 1099-R yet (will receive next year) and entered distributions as code J and P (since related to current year distributed before tax deadline and 2 previous years). I thought this would automatically populate Line 20 of Form 5329 but it did not.
Only the 2017 excess can be corrected with a return of contribution before the due date of your tax return, which will be reported on a code JP 2018 Form 1099-R, reportable on your 2017 tax return.
The excesses for 2015 and 2016 must be corrected by making a regular distribution from your Roth IRAs. Since this distribution occurred in 2018, it should be reported on a code J, T or Q 2018 Form 1099-R. The excess contributions made for 2015 and 2016 are still subject to penalty on your 2017. The code J, T or Q 2018 Form 1099-R will be reportable on your 2018 tax return and will eliminate the penalty on these excesses for 2018 and beyond by appearing on line 20 of your 2018 Form 5329.