The alphabet of a certain language consists only of three letters — 'a', 'o', and 'c'. Determine the maximum number of words of length N that can exist in the language if each letter of the alphabet can occur in a word no more than K times. For example, for N=2 and K=1 the answer is 6 (these are the words 'ao', 'oa', 'oc', 'co', 'ac', and 'ca'). For N=2 and K=2 the answer is 9, as the words 'aa', 'oo', 'cc' are added. Find the answers for the following pairs of values N and K:
To submit a solution in the Codeforces system, click the "Submit code" link (above the problem statement). In the "Source code" field, write four integers separated by spaces, without writing anything extra. In the "Language" field, select PHP.
Each correct answer is worth 25 points. The participant is informed of the total points scored.
During the Olympiad, participants had 10 attempts to submit a solution. There is no such restriction on Codeforces.