Professor Chang has nine different language books lined up on a bookshelf: two Arabic, three German, and four Spanish. Find the number of ways to arrange the nine books on the shelf keeping the Arabic books together and keeping the Spanish books together.

Let's think step by step and output the final answer within \boxed{}.
user