Two trolleys A and B are moving with accelerations a and 2a