\(C\) hits \(D\) and stops while \(D\) moves. at the same time,\(A\) hits \(B\) and stops, pushing \(B\).
Now \(B\) hits the now at rest \(C\) and comes to rest and \(C\) starts moving. Thus, in the end \(C\),\(D\) move to the right and \(A\),\(B\) stay at rest.