Roy and Biv have a set of n points on the infinite number line.
Each point has one of 3 colors: red, green, or blue.
Roy and Biv would like to connect all the points with some edges. Edges can be drawn between any of the two of the given points. The cost of an edge is equal to the distance between the two points it connects.
They want to do this in such a way that they will both see that all the points are connected (either directly or indirectly).
However, there is a catch: Roy cannot see the color red and Biv cannot see the color blue.
Therefore, they have to choose the edges in such a way that if all the red points are removed, the remaining blue and green points are connected (and similarly, if all the blue points are removed, the remaining red and green points are connected).
Help them compute the minimum cost way to choose edges to satisfy the above constraints.
Input
The first line will contain an integer n (1 ≤ n ≤ 300 000), the number of points.
The next n lines will contain two tokens p**i and c**i (p**i is an integer, 1 ≤ p**i ≤ 109, c**i is a uppercase English letter ‘R’, ‘G’ or ‘B’), denoting the position of the ith point and the color of the ith point. ‘R’ means red, ‘G’ denotes green, and ‘B’ means blue. The positions will be in strictly increasing order.
Output
Print a single integer, the minimum cost way to solve the problem.
Examples
input
1  4 
output
1  23 
input
1  4 
output
1  12 
Note
In the first sample, it is optimal to draw edges between the points (1,2), (1,4), (3,4). These have costs 4, 14, 5, respectively.
Solution
想出来没打完，是我太菜了，代码能力不行。
最开始被误导是网络流？然后看这范围应该是排序+贪心，然后都不用排序的
很显然，B和R连起来没用，无论是删B还是R，G都要连在一起。
所以就只有两种情况了，
 两个G之间的所有的B和R，连到两端的G，间隔最大的地方空掉（B和R互不影响），也就是3×两个G之间的距离最大的间隔（B和B的，R和R的分开），相邻的G和G相连
 两头的G和所有的B连一起，两头的G和所有的R连一起，也就是2×两个相邻的G之间的距离
两头的随便搞。
1 
