_ _ _ _ _ _ _ _. 8 seats to sit on. Mariya must be in seat 1 and Aofa can't be in seat 8, so for now we will put her on the second seat:
M A _ _ _ _ _ _. Then you got the 3 ppl that gotta be together so :
M A c m h _ _ _ _. For those 3 ppl, they have 4 patterns in which they can sit, and they can be arranged in 3!, so can the other 3 random ppl. So you got 4 x 3! x 3! Then we also gotta consider Asofa since he/she can also sit in the 7th or 6th seat or whatever seat but the last: This means she can sit in the 2nd, 3rd, 4th, 5th, 6th and 7th seat, so 6 seats she can sit in total
therefore: 4 x 3! x 3! x 6 = 864