{"trustable":false,"sections":[{"title":"","value":{"format":"PLAIN","content":"The people of Mohammadpur have decided to paint each of their houses red, green, or blue. They\u0027ve also decided that no two neighboring houses will be painted the same color. The neighbors of house i are houses i-1 and i+1. The first and last houses are not neighbors.\n\nYou will be given the information of houses. Each house will contain three integers \"R G B\" (quotes for clarity only), where R, G and B are the costs of painting the corresponding house red, green, and blue, respectively. Return the minimal total cost required to perform the work."}},{"title":"Input","value":{"format":"PLAIN","content":"Input starts with an integer T (≤ 100), denoting the number of test cases.\n\nEach case begins with a blank line and an integer n (1 ≤ n ≤ 20) denoting the number of houses. Each of the next n lines will contain 3 integers \"R G B\". These integers will lie in the range [1, 1000]."}},{"title":"Output","value":{"format":"PLAIN","content":"For each case of input you have to print the case number and the minimal cost."}},{"title":"Sample Input","value":{"format":"PLAIN","content":"3\n\n3\n4 18 15\n17 21 23\n25 8 25\n\n8\n2 17 10\n19 5 10\n8 24 14\n24 22 24\n11 10 25\n17 21 25\n7 5 15\n19 19 15\n\n9\n461 5 996\n495 26 310\n778 722 696\n376 799 432\n116 276 294\n651 258 243\n540 36 467\n538 22 289\n658 476 379"}},{"title":"Sample Output","value":{"format":"PLAIN","content":"Case 1: 35\nCase 2: 86\nCase 3: 2629\n"}},{"title":"Hint","value":{"format":"PLAIN","content":"Use simple DP"}}]}