Problem: Little Janet likes playing with cubes. Actually, she likes to play with anything whatsoever, cubes or tesseracts, as long as they are multicolored. Each cube is described by two parameters — color ci and size si. A Zebra Tower is a tower that consists of cubes of exactly two colors. Besides, the colors of the cubes in the tower must alternate (colors of adjacent cubes must differ). The Zebra Tower should have at least two cubes. There are no other limitations. The figure below shows an example of a Zebra Tower.

<image>

A Zebra Tower's height is the sum of sizes of all cubes that form the tower. Help little Janet build the Zebra Tower of the maximum possible height, using the available cubes.

Input

The first line contains an integer n (2 ≤ n ≤ 105) — the number of cubes. Next n lines contain the descriptions of the cubes, one description per line. A cube description consists of two space-separated integers ci and si (1 ≤ ci, si ≤ 109) — the i-th cube's color and size, correspondingly. It is guaranteed that there are at least two cubes of different colors.

Output

Print the description of the Zebra Tower of the maximum height in the following form. In the first line print the tower's height, in the second line print the number of cubes that form the tower, and in the third line print the space-separated indices of cubes in the order in which they follow in the tower from the bottom to the top. Assume that the cubes are numbered from 1 to n in the order in which they were given in the input.

If there are several existing Zebra Towers with maximum heights, it is allowed to print any of them. 

Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.

Examples

Input

4
1 2
1 3
2 4
3 3


Output

9
3
2 3 1 


Input

2
1 1
2 1


Output

2
2
2 1 

Solution (in PYTHON):

Solution:
N = int(raw_input())
cubes = dict()

for i in xrange(N):
    color, size = map(int, raw_input().split(' '))

    if color not in cubes:
        cubes[color] = []

    cubes[color].append((size, i))

bests = [[(-10**18, -1)] * (N + 5), [(-10**18, -1)] * (N + 5)]
bests[0][0] = bests[1][0] = (0, 0)

for color in cubes.iterkeys():
    cubes[color].sort(reverse = True)
    sizes = cubes[color]

    n = len(sizes)
    accum = 0

    for i in xrange(n):
        accum += sizes[i][0]

        if accum > bests[0][i + 1][0]:
            bests[1][i + 1], bests[0][i + 1] = bests[0][i + 1], (accum, color)
        elif accum > bests[1][i + 1][0]:
            bests[1][i + 1] = (accum, color)

best = (0, 0, 0, 0)
best_sum = -1

def check_best(list0, len0, list1, len1):
    global bests
    global best
    global best_sum

    pair0 = bests[list0][len0]
    pair1 = bests[list1][len1]

    if pair0[1] != pair1[1] and pair0[0] + pair1[0] > best_sum:
        best_sum = pair0[0] + pair1[0]
        best = (len0, list0, len1, list1)

for i in xrange(N + 1):
    check_best(0, i, 1, i)
    check_best(0, i, 0, i + 1)
    check_best(0, i, 1, i + 1)
    check_best(1, i, 0, i + 1)

answer = []

len0 = best[0]
list0 = best[1]
color0 = bests[list0][len0][1]
len1 = best[2]
list1 = best[3]
color1 = bests[list1][len1][1]
assert color0 != color1

ind0, ind1 = 0, 0
turn = 1

while ind0 < len0 or ind1 < len1:
    if turn == 0:
        answer.append(cubes[color0][ind0][1])
        ind0 += 1
        turn = 1
    else:
        answer.append(cubes[color1][ind1][1])
        ind1 += 1
        turn = 0

n = len(answer)
print best_sum
print n

for i in xrange(n):
    print answer[i] + 1,

print ''