|All-time Popular Problems|
|Find duplicates in an array|
|Triplet Sum in Array|
|Sorting Elements of an Array by Frequency|
|Search an Element in an array|
|Diameter of Binary Tree|
|Maximum of all subarrays of size k|
|Leaders in an array|
|Find median in a stream|
|Reverse a Linked List in groups of given size.|
You are provided an unlimited collection of red, green and blue balls. Now your task is to arrange N balls taken from this collection in a line in such a way that red balls appear first, followed by green balls and then blue balls. Given a value of N you have to find the number of ways to do that.
Note: In a particular arrangement a certain color of balls may be missing but the order must be strictly maintained with the available balls.
The first line of the input contains T, the number of test cases. Then T lines follow. Each test case contains one line only containing the value of N.
For each test case print the answer in a new line.
1. For the first test case you are allowed to take 1 ball only. So that one ball can be red, green or blue. So the number of ways in this case is 3.
2. For the second test case you are allowed to take 2 balls. So you have six alternative arrangements ie. RG,GB,RB,RR,GG,BB.