Hide

Problem F
Four Die Rolls

Ashley and Brandon are playing a game where they roll a six-sided dice four times. Each integer from $1$ to $6$ is on one face of the dice and all values are equally likely to appear. Each time they roll the dice, they write down the value that shows on the top face of the dice, eventually forming a four-digit integer.

Ashley wins if all four digits in the integers are different. Otherwise, Brandon wins.

The dice has been rolled from $1$ to $3$ times so far. Compute the number of different ways to roll the remaining times such that Ashley wins, and the number of different ways to roll the remaining dice such that Brandon wins. Two ways are different if the integers formed are different - for example, rolling a $1$, then a $2$, then a $3$, then a $4$ forms the integer $1234$, and is different from rolling a $1$, then a $2$, then a $4$, then a $3$, which would form the integer $1243$.

Input

The first line contains $n$ ($1 \le n \le 3$), which is the number of times the dice have been rolled so far.

The next line contains $n$ integers ranging from $1$ to $6$, which are the first $n$ rolls of the dice in order.

Output

Output two space-separated integers on one line, which are the number of ways to roll the remaining times such that Ashley wins, and the number of ways to roll the remaining dice such that Brandon wins.

Sample Input 1 Sample Output 1
2
1 2
12 24
Sample Input 2 Sample Output 2
2
3 3
0 36

Please log in to submit a solution to this problem

Log in