5. At a rectangular table, eight chairs are placed, four on one side and four opposite them on the other side. In how many ways can eight friends be seated at this table so that Ana and Bane do not sit opposite each other, and Vesna and Goran sit next to each other? (It is known that all friends have distinct names.)

## Second Grade - B Category
5. We can choose the country for Vesna and Goran in 2 ways, their position as a pair in 3 ways, and their mutual arrangement in 2 ways, i.e., we can arrange them in 12 ways. If Ana and Bane sit on the opposite side relative to Vesna and Goran, we can arrange them in $12(=4 \cdot 3)$ ways; if Ana and Bane sit on the same side as Vesna and Goran, we can arrange them in 2 ways; if Ana and Bane sit on different sides, then we can choose the position on the side where Vesna and Goran are in 2 ways, then who of the two will be at that position in 2 ways, and finally the position for the other person in 3 ways. Thus, we can arrange Ana and Bane in $12+2+2 \cdot 2 \cdot 3=26$ ways. For the remaining 4 guests, there are 4 free seats, so we can arrange them in 4! ways. Therefore, the total number of arrangements is $12 \cdot 26 \cdot 4!=7488$.

## Second Grade - B Category