5. (30 points) In the royal dining hall, there are three tables, and three identical pies are served. For lunch, the king invited six princes to his table. At the second table, one can seat from 12 to 18 courtiers, and at the third table, from 10 to 20 knights. Each pie is cut into equal pieces according to the number of people sitting at the table. There is a rule at the court - the lunch of a knight together with the lunch of a courtier equals the lunch of the king. Determine the maximum possible number of knights the king can invite to lunch on this day. How many courtiers will sit at their table in this case?