B. Vitaminstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland shop sells n kinds of juices. Each juice has its price c_i. Each juice includes some set of vitamins in it. There are three types of vitamins: vitamin "A", vitamin "B" and vitamin "C". Each juice can contain one, two or all three types of vitamins in it.Petya knows that he needs all three types of vitamins to stay healthy. What is the minimum total price of juices that Petya has to buy to obtain all three vitamins? Petya obtains some vitamin if he buys at least one juice containing it and drinks it.InputThe first line contains a single integer n (1 \le n \le 1\,000) — the number of juices.Each of the next n lines contains an integer c_i (1 \le c_i \le 100\,000) and a string s_i — the price of the i-th juice and the vitamins it contains. String s_i contains from 1 to 3 characters, and the only possible characters are "A", "B" and "C". It is guaranteed that each letter appears no more than once in each string s_i. The order of letters in strings s_i is arbitrary.OutputPrint -1 if there is no way to obtain all three vitamins. Otherwise print the minimum total price of juices that Petya has to buy to obtain all three vitamins.ExamplesInput45 C6 B16 BAC4 AOutput15Input210 AB15 BAOutput-1Input510 A9 BC11 CA4 A5 BOutput13Input6100 A355 BCA150 BC160 AC180 B190 CAOutput250Input25 BA11 CBOutput16NoteIn the first example Petya buys the first, the second and the fourth juice. He spends 5 + 6 + 4 = 15 and obtains all three vitamins. He can also buy just the third juice and obtain three vitamins, but its cost is 16, which isn't optimal.In the second example Petya can't obtain all three vitamins, as no juice contains vitamin "C".
Input45 C6 B16 BAC4 A
Output15
['bitmasks', 'brute force', 'dp', 'implementation', '*1200']