A bakery produces two types of bread, M and N. For each loaf of M sold, the profit is $6, and for each loaf of N, the profit is $18. The bakery uses 120 cups of flour and has an oven time of 6 hours daily. Producing one loaf of M consumes 3 cups of flour and takes 2 hours, while one loaf of N consumes 5 cups of flour and takes 1 hour. What's the maximum profit?