Work is equal to a force applied over a net distance (aka displacement) . Net distance is the difference between your starting and ending point. So if you push a box from point A to point B, and then push it back from point B to point A, no work will be done.
In your diagram, for part 1, it looks like the first box is being pushed to the right by a force pointed to the right, so positive work is being done on that box. The second box is being pushed to the left by a force pointed to the left, so the work being done on that box is also positive. It doesn't matter if the boxes are going in different directions, they are both being moved with positive work.
however, in your second part, it looks like you push the boxes back to their starting positions, so the overall work for the first and second part would be zero since the boxes don't have a change in displacement.