How to determine custodian for child care deduction

What are the IRS rules for taking a child care deduction in this (complicated) situation:

 

1) Preschool child expense incurred from 1/1/19 to 6/1/19

2) Mother is custodial parent in orders prior to  11/1/2019.  Father is custodial parent after 11/1/2019 per new parenting plan.

3) 50/50 residential schedule after 8/7/2019

 

My question is who takes the child care deduction?