Here are a few spacetime diagrams. If you haven't come across them, they're simply plots of the position of an object over time, the custom being that time goes up the page. So a vertical line represents an object that isn't moving, and a line slanted to the left indicates one moving to the left. You may have come across these (usually with time horizontally) as "displacement-time graphs" in high school physics. We take them a little more seriously in relativity, since spacetime is a thing - these are maps of spacetime, and the lines are the 4d objects inhabiting it. You see one 3d slice at a time.
So here's your scenario, with my extra "D" observer. A and B are marked in red and are stationary, C and D are marked in blue and moving to the right.
View attachment 341321
Note that, in this frame, C and D are closer together than A and B - the horizontal distance between the lines ("the space between them") is shorter.
We could mark on the diagram the start and end of the experiment - when C passes A and then B. Let's do that with fine red lines:
[snip]