Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:

There are $n$ new cities located in Prefecture X. Cities are numbered from $1$ to $n$. City $i$ is located $x_i$ km North of the shrine and $y_i$ km East of the shrine. It is possible that $(x_i, y_i) = (x_j, y_j)$ even when $i \ne j$.

Shichikuji must provide electricity to each city either by building a power station in that city, or by making a connection between that city and another one that already has electricity. So the City has electricity if it has a power station in it or it is connected to a City which has electricity by a direct connection or via a chain of connections.

    Building a power station in City $i$ will cost $c_i$ yen;     Making a connection between City $i$ and City $j$ will cost $k_i + k_j$ yen per km of wire used for the connection. However, wires can only go the cardinal directions (North, South, East, West). Wires can cross each other. Each wire must have both of its endpoints in some cities. If City $i$ and City $j$ are connected by a wire, the wire will go through any shortest path from City $i$ to City $j$. Thus, the length of the wire if City $i$ and City $j$ are connected is $|x_i - x_j| + |y_i - y_j|$ km. 

Shichikuji wants to do this job spending as little money as possible, since according to her, there isn't really anything else in the world other than money. However, she died when she was only in fifth grade so she is not smart enough for this. And thus, the new resident deity asks for your help.

And so, you have to provide Shichikuji with the following information: minimum amount of yen needed to provide electricity to all cities, the cities in which power stations will be built, and the connections to be made.

If there are multiple ways to choose the cities and the connections to obtain the construction of minimum price, then print any of them.


-----Input-----

First line of input contains a single integer $n$ ($1 \leq n \leq 2000$) — the number of cities.

Then, $n$ lines follow. The $i$-th line contains two space-separated integers $x_i$ ($1 \leq x_i \leq 10^6$) and $y_i$ ($1 \leq y_i \leq 10^6$) — the coordinates of the $i$-th city.

The next line contains $n$ space-separated integers $c_1, c_2, \dots, c_n$ ($1 \leq c_i \leq 10^9$) — the cost of building a power station in the $i$-th city.

The last line contains $n$ space-separated integers $k_1, k_2, \dots, k_n$ ($1 \leq k_i \leq 10^9$).


-----Output-----

In the first line print a single integer, denoting the minimum amount of yen needed.

Then, print an integer $v$ — the number of power stations to be built.

Next, print $v$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $1$ to $n$ and all numbers should be pairwise distinct. You can print the numbers in arbitrary order.

After that, print an integer $e$ — the number of connections to be made.

Finally, print $e$ pairs of integers $a$ and $b$ ($1 \le a, b \le n$, $a \ne b$), denoting that a connection between City $a$ and City $b$ will be made. Each unordered pair of cities should be included at most once (for each $(a, b)$ there should be no more $(a, b)$ or $(b, a)$ pairs). You can print the pairs in arbitrary order.

If there are multiple ways to choose the cities and the connections to obtain the construction of minimum price, then print any of them.


-----Examples-----
Input
3
2 3
1 1
3 2
3 2 3
3 2 3

Output
8
3
1 2 3 
0

Input
3
2 1
1 2
3 3
23 2 23
3 2 3

Output
27
1
2 
2
1 2
2 3



-----Note-----

For the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):

[Image]

For the first example, the cost of building power stations in all cities is $3 + 2 + 3 = 8$. It can be shown that no configuration costs less than 8 yen.

For the second example, the cost of building a power station in City 2 is 2. The cost of connecting City 1 and City 2 is $2 \cdot (3 + 2) = 10$. The cost of connecting City 2 and City 3 is $3 \cdot (2 + 3) = 15$. Thus the total cost is $2 + 10 + 15 = 27$. It can be shown that no configuration costs less than 27 yen.

Difficulty: interview

Starter code:

Solutions:
from math import *

c=int(input())
x=[0]*c
y=[0]*c
vu=[False]*c
for i in range(c):
    x[i],y[i]=[int(s) for s in input().split()]
prix=[int(s) for s in input().split()]
fil=[int(s) for s in input().split()]
anc=[-1]*c
pmin=prix.copy()
v=0
pl=[]
e=0
ppl=[]
tot=0
for i in range(c):
    pmina=100000000000000000000000
    for j in range(c):
        if (not vu[j]) and pmin[j]<pmina:
            pmini=j
            pmina=pmin[j]
    vu[pmini]=True
    tot+=pmina
    if anc[pmini]==-1:
        v+=1
        pl.append(str(pmini+1))
    else:
        e+=1
        ppl.append([str(pmini+1),str(anc[pmini]+1)])
    for j in range(c):
        if (abs(x[pmini]-x[j])+abs(y[pmini]-y[j]))*(fil[pmini]+fil[j])<pmin[j]:
            pmin[j]=(abs(x[pmini]-x[j])+abs(y[pmini]-y[j]))*(fil[pmini]+fil[j])
            anc[j]=pmini
print(tot)
print(v)
print(" ".join(pl))
print(e)
for i in ppl:
    print(" ".join(i))

N = int(input())  # 市の数
XY = [list(map(int, input().split())) for _ in range(N)]
C = list(map(int, input().split()))  # 市 i に発電所を建てるコスト
K = list(map(int, input().split()))  # つなげるコスト

CC = [-1] * N
Ans = [-2] * N
total_cost = 0
for _ in range(N):
    mi = float("inf")
    for i, (c, an) in enumerate(zip(C, Ans)):
        if an == -2 and mi > c:
            mi = c
            ami = i
    total_cost += mi
    Ans[ami] = CC[ami]
    k1 = K[ami]
    x1, y1 = XY[ami]
    for i, (k2, (x2, y2)) in enumerate(zip(K, XY)):
        new_cost = (k1+k2) * (abs(x1-x2)+abs(y1-y2))
        if C[i] > new_cost:
            C[i] = new_cost
            CC[i] = ami
print(total_cost)
cnt = Ans.count(-1)
print(cnt)
A = []
B = []
for i, a in enumerate(Ans, 1):
    if a==-1:
        A.append(i)
    else:
        B.append((i, a+1))
print(" ".join(map(str, A)))
print(N - cnt)
for a, b in B:
    print(a, b)


import sys
input = sys.stdin.readline

n=int(input())
T=[tuple(map(int,input().split())) for i in range(n)]
C=list(map(int,input().split()))
K=list(map(int,input().split()))

import heapq
H=[]

for i,c in enumerate(C):
    H.append((c,i+1))

heapq.heapify(H)

ANS=0
USE=[0]*(n+1)
ANS1=[]
ANS2=[]

while H:
    x=heapq.heappop(H)
    #print(x)
    #print(H)

    if len(x)==2:
        cost,town=x

        if USE[town]==1:
            continue

        ANS+=cost
        USE[town]=1
        ANS1.append(town)

        xt,yt=T[town-1]

        for i in range(n):
            if USE[i+1]==1:
                continue
            costp=(abs(T[i][0]-xt)+abs(T[i][1]-yt))*(K[i]+K[town-1])
            #print(costp,xt,yt,i)
            if costp<C[i]:
                C[i]=costp
                heapq.heappush(H,(costp,town,i+1))

    else:
        cost,town1,town2=x
        if USE[town1]==1 and USE[town2]==1:
            continue

        ANS+=cost
        USE[town2]=1
        ANS2.append((town1,town2))

        xt,yt=T[town2-1]

        for i in range(n):
            if USE[i+1]==1:
                continue
            costp=(abs(T[i][0]-xt)+abs(T[i][1]-yt))*(K[i]+K[town2-1])
            if costp<C[i]:
                C[i]=costp
                heapq.heappush(H,(costp,town2,i+1))

sys.stdout.write(str(ANS)+"\n")
sys.stdout.write(str(len(ANS1))+"\n")
print(*ANS1)

sys.stdout.write(str(len(ANS2))+"\n")
for x,y in ANS2:
    sys.stdout.write(str(x)+" "+str(y)+"\n")

        
            
        
        


import sys

# inf = open('input.txt', 'r')
# reader = (map(int, line.split()) for line in inf)
reader = (map(int, s.split()) for s in sys.stdin)

n, = next(reader)
cities = [None]
for _ in range(n):
    x, y = next(reader)
    cities.append((x, y))
cs = [None] + list(next(reader))
ks = [None] + list(next(reader))

n += 1
g = [[None] * n for _ in range(n)]
for i in range(1, n):
    for j in range(i + 1, n):
        wire = ks[i] + ks[j]
        dist = abs(cities[i][0] - cities[j][0]) + \
                abs(cities[i][1] - cities[j][1])
        g[i][j] = g[j][i] = wire * dist
for i in range(1, n):
    g[0][i] = g[i][0] = cs[i]
for i in range(n):
    g[i][i] = float('inf')

totalCost = 0
stations = []
connections = []

used = [False] * n
min_e = [float('inf')] * n
sel_e = [-1] * n

start = 0  # starting from 0-node (dummy node)
min_e[start] = 0
for i in range(n):
    v = -1
    for j in range(n):
        if (not used[j] and (v == -1 or min_e[j] < min_e[v])):
            v = j
#     if min_e[v] == float('inf'): break
    used[v] = True

    fromNode = sel_e[v]
    if not fromNode:  # edge (0, v) <=> v-node has station
        totalCost += g[v][fromNode]
        stations.append(v)
    elif fromNode > 0:
        totalCost += g[v][fromNode]
        connections.append((v, fromNode))
        
    for to in range(n):
        if g[v][to] < min_e[to]:
            min_e[to] = g[v][to]
            sel_e[to] = v

print(totalCost)
print(len(stations))
print(*stations)
print(len(connections))
[print(c1, c2) for c1, c2 in connections];
    
# inf.close()

import sys


# inf = open('input.txt', 'r')
# reader = (map(int, line.split()) for line in inf)
reader = (list(map(int, s.split())) for s in sys.stdin)

n, = next(reader)
cities = [None]
for _ in range(n):
    x, y = next(reader)
    cities.append((x, y))
cs = [None] + list(next(reader))
ks = [None] + list(next(reader))

n += 1  # extra 0 node (dummy node); edge (0, v) <=> v-node has station
g = [[None] * n for _ in range(n)]
for i in range(1, n):
    for j in range(i + 1, n):
        wire = ks[i] + ks[j]
        dist = abs(cities[i][0] - cities[j][0]) + \
                abs(cities[i][1] - cities[j][1])
        g[i][j] = g[j][i] = wire * dist
for i in range(1, n):
    g[0][i] = g[i][0] = cs[i]
for i in range(n):
    g[i][i] = float('inf')

totalCost = 0
stations = []
connections = []

used = [False] * n
min_e = [float('inf')] * n
sel_e = [-1] * n

start = 0  # starting from 0-node (dummy node)
min_e[start] = 0
for i in range(n):
    v = -1
    for j in range(n):
        if (not used[j] and (v == -1 or min_e[j] < min_e[v])):
            v = j
#     if min_e[v] == float('inf'): break
    used[v] = True

    fromNode = sel_e[v]
    if not fromNode:  # edge (0, v) <=> v-node has station
        totalCost += g[v][fromNode]
        stations.append(v)
    elif fromNode > 0:
        totalCost += g[v][fromNode]
        connections.append((v, fromNode))
        
    for to in range(n):
        if g[v][to] < min_e[to]:
            min_e[to] = g[v][to]
            sel_e[to] = v

myprint = sys.stdout.write
myprint(str(totalCost) + '\n')
myprint(str(len(stations)) + '\n')
[myprint(str(st) + ' ') for st in stations];
myprint(str(len(connections)) + '\n')
[myprint(str(c1) + ' ' + str(c2) + '\n') for c1, c2 in connections];

# print(totalCost)
# print(len(stations))
# print(*stations)
# print(len(connections))
# [print(c1, c2) for c1, c2 in connections];
    
# inf.close()


import sys


# inf = open('input.txt', 'r')
# reader = (map(int, line.split()) for line in inf)
reader = (list(map(int, s.split())) for s in sys.stdin)

n, = next(reader)
locs = [tuple(next(reader)) for _ in range(n)]
cs = list(next(reader))
ks = list(next(reader))

totalCost = 0
stations = []
connections = []

connCosts = {i: cost for i, cost in enumerate(cs)}
connTo = [-1] * n
while connCosts:
    v = min(connCosts, key=connCosts.get)
    totalCost += connCosts[v]
    
    if connCosts[v] < cs[v]:
        to = connTo[v]
        connections.append((v, to))        
    else:
        stations.append(v)
        
    connCosts.pop(v)
    for to, cost in list(connCosts.items()):
        wire = ks[v] + ks[to]
        dist = abs(locs[v][0] - locs[to][0]) + \
                abs(locs[v][1] - locs[to][1])
        newCost = wire * dist
        if connCosts[to] > newCost:
            connCosts[to] = newCost
            connTo[to] = v
            
myprint = sys.stdout.write
myprint(str(totalCost) + '\n')
myprint(str(len(stations)) + '\n')
[myprint(str(st + 1) + ' ') for st in stations];
myprint(str(len(connections)) + '\n')
[myprint(str(c1 + 1) + ' ' + str(c2 + 1) + '\n') for c1, c2 in connections];

# print(totalCost)
# print(len(stations))
# print(*(st + 1 for st in stations))
# print(len(connections))
# [print(c1 + 1, c2 + 1) for c1, c2 in connections];
    
# inf.close()


# refactored Prim's algorithm 
# (with dummy 0-node)
import sys


# inf = open('input.txt', 'r')
# reader = (map(int, line.split()) for line in inf)
reader = (list(map(int, s.split())) for s in sys.stdin)

n, = next(reader)
cities = [None]
for _ in range(n):
    x, y = next(reader)
    cities.append((x, y))
cs = [None] + list(next(reader))
ks = [None] + list(next(reader))

n += 1  # extra dummy 0-node (source of power); edge (0, v) = c_v
g = [[None] * n for _ in range(n)]
for i in range(1, n):
    for j in range(i + 1, n):
        wire = ks[i] + ks[j]
        dist = abs(cities[i][0] - cities[j][0]) + \
                abs(cities[i][1] - cities[j][1])
        g[i][j] = g[j][i] = wire * dist
for i in range(1, n):
    g[0][i] = g[i][0] = cs[i]
for i in range(n):
    g[i][i] = float('inf')

totalCost = 0
stations = []
connections = []

connCosts = {i: float('inf') for i in range(n)}
connTo = [-1] * n

start = 0  # starting from dummy node
connCosts[start] = 0
while connCosts:
    # node with min connection cost
    v = min(connCosts, key=connCosts.get)
    if connCosts[v] == float('inf'): break

    fromNode = connTo[v]
    if not fromNode:  # edge (0, v) <=> v-node has station
        totalCost += g[v][fromNode]
        stations.append(v)
    elif fromNode > 0:
        totalCost += g[v][fromNode]
        connections.append((v, fromNode))
        
    connCosts.pop(v)
    for to, cost in list(connCosts.items()):
        if g[v][to] < connCosts[to]:
            connCosts[to] = g[v][to]
            connTo[to] = v

myprint = sys.stdout.write
myprint(str(totalCost) + '\n')
myprint(str(len(stations)) + '\n')
[myprint(str(st) + ' ') for st in stations];
myprint(str(len(connections)) + '\n')
[myprint(str(c1) + ' ' + str(c2) + '\n') for c1, c2 in connections];

# print(totalCost)
# print(len(stations))
# print(*stations)
# print(len(connections))
# [print(c1, c2) for c1, c2 in connections];
    
# inf.close()


def prim(matrix, inf=10**18):
    n = len(matrix)
    costs = [inf] + [inf-1]*(n-1)
    nearest = [-1]*n
    current = 0
    total_cost = 0

    build, connect = [], []

    for _ in range(n-1):
        min_cost = inf
        src, dest = -1, -1

        for i in range(n):
            if costs[i] == inf:
                continue
            if matrix[current][i] < costs[i]:
                costs[i] = matrix[current][i]
                nearest[i] = current
            if min_cost > costs[i]:
                min_cost = costs[i]
                src, dest = nearest[i], i

        total_cost += min_cost
        costs[dest] = inf

        if src == 0:
            build.append(dest)
        else:
            connect.append('%d %d' % (src, dest))

        current = dest

    return build, connect, total_cost


def __starting_point():
    import sys
    n = int(input())
    pos = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
    c_costs = list(map(int, input().split()))
    k_costs = list(map(int, input().split()))

    inf = 10**18
    matrix = [[inf]*(n+1) for _ in range(n+1)]

    for i in range(n):
        for j in range(i+1, n):
            matrix[i+1][j+1] = matrix[j+1][i+1] = \
                (abs(pos[i][0]-pos[j][0]) + abs(pos[i][1]-pos[j][1])) * (k_costs[i]+k_costs[j])

        matrix[i+1][0] = matrix[0][i+1] = c_costs[i]

    build, connect, cost = prim(matrix)
    print(cost)
    print(len(build))
    print(*build)
    print(len(connect))
    if connect:
        print(*connect, sep='\n')

__starting_point()

def prim_matrix(matrix: list, inf=10**18):
    n = len(matrix)
    costs, unused = [inf]*n, [0]+[1]*(n-1)
    current = 0
    total_cost = 0

    nearest = [-1]*n
    build, connect = [], []

    for _ in range(n-1):
        min_cost = inf
        dest = -1
        src = -1

        for i in range(n):
            if unused[i]:
                if matrix[current][i] < costs[i]:
                    costs[i] = matrix[current][i]
                    nearest[i] = current
                if min_cost > costs[i]:
                    min_cost = costs[i]
                    dest = i
                    src = nearest[i]

        total_cost += min_cost
        unused[dest] = 0

        if src == 0:
            build.append(dest)
        else:
            connect.append('%d %d' % (src, dest))
        current = dest

    print(total_cost)
    print(len(build))
    print(*build)
    print(len(connect))
    if connect:
        print(*connect, sep='\n')

    return total_cost


def __starting_point():
    import sys
    n = int(input())
    pos = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
    c_costs = list(map(int, input().split()))
    k_costs = list(map(int, input().split()))

    inf = 10**18
    matrix = [[inf]*(n+1) for _ in range(n+1)]

    for i in range(n):
        for j in range(i+1, n):
            matrix[i+1][j+1] = matrix[j+1][i+1] = \
                (abs(pos[i][0]-pos[j][0]) + abs(pos[i][1]-pos[j][1])) * (k_costs[i]+k_costs[j])

        matrix[i+1][0] = matrix[0][i+1] = c_costs[i]

    cost = prim_matrix(matrix)

__starting_point()

import sys

reader = (list(map(int, s.split())) for s in sys.stdin)
 
n, = next(reader)
xy = []
for _ in range(n):
    x, y = next(reader)
    xy.append([x, y])
c = list(next(reader))
k = list(next(reader))


# n = int(input())
# xy = [[]]*n
# for i in range(n):
#     xy[i] = list(map(int,input().split()))

# c = list(map(int,input().split()))
# k = list(map(int,input().split()))

graph = [[0 for _ in range(n+1)] for _i in range(n+1)]

for i in range(n):
    for j in range(i+1,n):
        cost = (abs(xy[i][0]-xy[j][0])+abs(xy[i][1]-xy[j][1]))*(k[i]+k[j])
        graph[i][j] = graph[j][i] = cost
    graph[n][i] = graph[i][n] = c[i]

# def output(parent):
#     es = []
#     vs = []
#     cost = 0
#     for i in range(1,(n+1)):
#         if parent[i]==n:
#             vs.append(i+1)
#         elif i==n:
#             vs.append(parent[i]+1)
#         else:
#             es.append([i+1,parent[i]+1])
#         cost+= graph[i][parent[i]]
#     print(cost)
#     print(len(vs))
#     print(*vs)
#     print(len(es))
#     for i in es:
#         print(i[0],i[1])
            

# def minKey(key, mstSet): 
#     # Initilaize min value 
#     min = 1000000000000 

#     for v in range((n+1)): 
#         if key[v] < min and mstSet[v] == False: 
#             min = key[v] 
#             min_index = v 

#     return min_index 

def primMST():
    # Key values used to pick minimum weight edge in cut 
    key = [1000000000000] * (n+1)
    parent = [None] * (n+1) # Array to store constructed MST 
    # Make key 0 so that this vertex is picked as first vertex 
    key[0] = 0 
    mstSet = [False] * (n+1) 

    parent[0] = -1 # First node is always the root of 

    for cout in range((n+1)): 

        # Pick the minimum distance vertex from  
        # the set of vertices not yet processed.  
        # u is always equal to src in first iteration 
        mn = 1000000000000 

        for v in range((n+1)): 
            if key[v] < mn and mstSet[v] == False: 
                mn = key[v] 
                min_index = v 

        u = min_index 

        # Put the minimum distance vertex in  
        # the shortest path tree 
        mstSet[u] = True

        # Update dist value of the adjacent vertices  
        # of the picked vertex only if the current  
        # distance is greater than new distance and 
        # the vertex in not in the shotest path tree 
        for v in range((n+1)): 
            # graph[u][v] is non zero only for adjacent vertices of m 
            # mstSet[v] is false for vertices not yet included in MST 
            # Update the key only if graph[u][v] is smaller than key[v] 
            if graph[u][v] > 0 and mstSet[v] == False and key[v] > graph[u][v]: 
                    key[v] = graph[u][v] 
                    parent[v] = u
        
    # es = []
    vss = 0
    # vs = []
    cost = 0
    for i in range(1,(n+1)):
        if parent[i]==n or i==n:
            vss += 1
        #     vs.append(i+1)
        # elif i==n:
        #     vs.append(parent[i]+1)
        # else:
        #     es.append([i+1,parent[i]+1])
        cost+= graph[i][parent[i]]
    
    myprint = sys.stdout.write

    myprint(str(cost) + '\n')
    # print(cost)
    # print(vss)
    myprint(str(vss)+'\n')
    

    vs = [0]*(vss)
    es = [[]]*(n-vss)
    k1,k2 = 0,0

    for i in range(1,(n+1)):
        if parent[i]==n:
            vs[k1] = i+1
            k1+=1
        elif i==n:
            vs[k1] = parent[i]+1
            k1+=1
        else:
            es[k2] = [i+1,parent[i]+1]
            k2+=1
        # cost+= graph[i][parent[i]]

    # print(*vs)
    [myprint(str(st) + ' ') for st in vs]
    myprint('\n')
    myprint(str(len(es))+'\n')
    [myprint(str(i[0]) + ' ' + str(i[1]) + '\n') for i in es]
    # print(len(es))
    # for i in es:
    #     print(i[0],i[1])
        
    
    
    # myprint(str(totalCost) + '\n')
    # myprint(str(len(stations)) + '\n')
    # [myprint(str(st) + ' ') for st in stations];
    # myprint(str(len(connections)) + '\n')
    # [myprint(str(c1) + ' ' + str(c2) + '\n') for c1, c2 in connections];


primMST()

# e = 0
# i=0
# ans = []
# ret = 0
# while e<n:
#     edge = edges[i]
#     i+=1
#     cost,a,b = edge
#     if find(a)!=find(b):
#         e+=1
#         ans.append([cost,a,b])
#         union(a,b)
#         ret += cost

# vs = []
# es = []
# for i in ans:
#     if i[1]==n:
#         vs.append(i[2]+1)
#     else:
#         es.append(i)

# print(ret)
# print(len(vs))
# print(*vs)
# print(len(es))
# for i in es:
#     print(i[1]+1,i[2]+1)



from collections import deque
from math import inf

def run_testcase():
	n = int(input())

	coords = [None] * (n + 1)

	for i in range(1, n + 1):
		coords[i] = [int(x) for x in input().split()]

	ci = [0] + [int(x) for x in input().split()]
	ki = [0] + [int(x) for x in input().split()]


	def cost(i, j):
		if i == j:
			return 0

		if i > j:
			i, j = j, i

		if i == 0:
			return ci[j]

		return (abs(coords[i][0] - coords[j][0]) + abs(coords[i][1] - coords[j][1])) * (ki[i] + ki[j])


	current_cost = 0
	tree = set([0])
	rest = set(range(1, n + 1))
	included = [True] + [False] * n
	connections = deque()
	connections_to_station = 0

	# min_attach_cost = [0] + [inf] * n
	# min_attach_cost = [0] + [cost(0, j) for j in range(1, n + 1)]
	min_attach_cost = [(0, 0)] + [(cost(0, j), 0) for j in range(1, n + 1)]


	while len(tree) < n + 1:
		min_pair = (0, 0)
		min_cost = inf
		# for tree_node in tree:
		# 	for i in range(1, n + 1):
		# 		if included[i]:
		# 			continue
		# 		curr_cost = cost(tree_node, i)
		# 		if curr_cost < min_cost:
		# 			min_pair = (tree_node, i)
		# 			min_cost = curr_cost

		for node in rest:
			if min_attach_cost[node][0] < min_cost:
				min_pair = (min_attach_cost[node][1], node)
				min_cost = min_attach_cost[node][0]



		tree.add(min_pair[1])
		included[min_pair[1]] = True
		current_cost += min_cost

		rest.remove(min_pair[1])
		for node in rest:
			if cost(min_pair[1], node) < min_attach_cost[node][0]:
				min_attach_cost[node] = (cost(min_pair[1], node), min_pair[1])

		min_pair = tuple(sorted(min_pair))

		if min_pair[0] == 0:
			connections.appendleft(min_pair)
			connections_to_station += 1
		else:
			connections.append(min_pair)

	connections_list = list(connections)

	print(current_cost)
	print(connections_to_station)
	print(' '.join([str(x[1]) for x in connections_list[:connections_to_station]]))

	print(len(connections_list) - connections_to_station)
	for i in range(connections_to_station, len(connections_list)):
		print(connections_list[i][0], connections_list[i][1])






# testcase_count = int(input())

# for i in range(testcase_count):
# 	print(str(run_testcase()))

run_testcase()


N = int(input())  # 市の数
XY = [list(map(int, input().split())) for _ in range(N)]
C = list(map(int, input().split()))  # 市 i に発電所を建てるコスト
K = list(map(int, input().split()))  # つなげるコスト
 
CC = [-1] * N
Ans = [-2] * N
total_cost = 0
for _ in range(N):
    mi = float("inf")
    for i, (c, an) in enumerate(zip(C, Ans)):
        if an == -2 and mi > c:
            mi = c
            ami = i
    total_cost += mi
    Ans[ami] = CC[ami]
    k1 = K[ami]
    x1, y1 = XY[ami]
    for i, (k2, (x2, y2)) in enumerate(zip(K, XY)):
        new_cost = (k1+k2) * (abs(x1-x2)+abs(y1-y2))
        if C[i] > new_cost:
            C[i] = new_cost
            CC[i] = ami
print(total_cost)
cnt = Ans.count(-1)
print(cnt)
A = []
B = []
for i, a in enumerate(Ans, 1):
    if a==-1:
        A.append(i)
    else:
        B.append((i, a+1))
print(" ".join(map(str, A)))
print(N - cnt)
for a, b in B:
    print(a, b)

n=int(input())
pos=[[*map(int,input().split())] for i in range(n)]
*c,=map(int, input().split())
*k,=map(int, input().split())
used = [False for i in range(n)]
parent = [-1 for i in range(n)]
plants = []
connections = []
ans = 0
_n = n
while(_n):
    _n -= 1
    mn, u = min([(ci, i) for i, ci in enumerate(c) if not used[i]])
    ans += mn
    used[u] = True
    if parent[u] == -1:
        plants.append(u)
    else:
        connections.append((min(parent[u], u), max(parent[u], u)))
    for i in range(n):
        con_cost = (k[u] + k[i])*(abs(pos[u][0]-pos[i][0])+abs(pos[u][1]-pos[i][1]))
        if con_cost < c[i]:
            c[i] = con_cost
            parent[i] = u
print(ans)
print(len(plants))
for p in sorted(plants):
    print(p+1, end=' ')
print('')
print(len(connections))
for con in connections:
    print(con[0]+1, con[1]+1)


n = int(input())
cord = [[*map(int, input().split())]for _ in range(n)]
c = [*map(int, input().split())]
k = [*map(int, input().split())]
plant = set()
covered = set()
parent = [-1] * n
sum = 0
for _ in range(n):
    cost, idx = min([cost, idx] for idx, cost in enumerate(c) if idx not in covered)
    sum += cost
    covered.add(idx)
    if parent[idx] == -1:
        plant.add(idx)
    for i in range(n):
        if i in covered:
            continue
        c_l = (k[i]+k[idx])*(abs(cord[i][0]-cord[idx][0])+abs(cord[i][1]-cord[idx][1]))
        if c_l <c[i]:
            c[i] = c_l
            parent[i] = idx
print('{}\n{}'.format(sum, len(plant)))
print(*map(lambda x: x+1, plant))
links = 0
out = ''
for i, _ in enumerate(parent):
    if _ != -1:
        links += 1
        out += '\n' + str(_+1) + ' ' + str(i+1)
print(links, out)

import bisect
import functools
import math
import sys
from collections import defaultdict

# input = sys.stdin.readline
rt = lambda: map(int, input().split())
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))


def dist(x1, y1, x2, y2):
    return abs(x1-x2)+abs(y1-y2)

def main():
    n = ri()
    x, y = [0] * n, [0] * n
    for i in range(n):
        x[i], y[i] = rt()
    c = rl()
    k = rl()

    val = c.copy()
    used = [False] * n
    link = [-1] * n
    to_build = []
    for _ in range(n):  # each step removes 1 city
        # find min
        min_index = -1
        min_val = math.inf
        for i in range(n):
            if not used[i] and val[i] < min_val:
                min_index = i
                min_val = val[i]

        used[min_index] = True
        if link[min_index] == -1:
            to_build.append(min_index+1)
        for i in range(n):
            if not used[i]:
                to_link  = (k[i]+k[min_index])*dist(x[i], y[i], x[min_index], y[min_index])
                if to_link < val[i]:
                    val[i] = to_link
                    link[i] = min_index

    print(sum(val))
    print(len(to_build))
    print(*to_build)
    print(len([x for x in link if x > -1]))
    for i in range(n):
        if link[i] > -1:
            print(i+1, link[i]+1)

def __starting_point():
    main()
__starting_point()

n=int(input())
X=[[0]*7 for _ in range(n)]
for i in range(n):
  x,y=map(int,input().split())
  X[i][0]=i+1
  X[i][1]=x
  X[i][2]=y
C=[int(i) for i in input().split()]
K=[int(i) for i in input().split()]
for i in range(n):
  X[i][3]=C[i]
  X[i][4]=K[i]
X.sort(key=lambda x:x[3])
ans_am=0
ans_ps=0
Ans=[]
ans_con=0
Con=[]

while X:
  ind,x,y,c,k,flag,source=X.pop(0)
  ans_am+=c
  if flag==0:
    ans_ps+=1
    Ans.append(ind)
  else:
    ans_con+=1
    Con.append([ind,source])
  for i in range(len(X)):
    indi,xi,yi,ci,ki,flagi,sourcei=X[i]
    if (k+ki)*(abs(x-xi)+abs(y-yi))<ci:
      X[i][3]=(k+ki)*(abs(x-xi)+abs(y-yi))
      X[i][5]=1
      X[i][6]=ind
  X.sort(key=lambda x:x[3])

print(ans_am)
print(ans_ps)
print(*Ans)
print(ans_con)
for i,j in Con:
  print(i,j)

n=int(input())
X=[[0]*7 for _ in range(n)]
for i in range(n):
  x,y=map(int,input().split())
  X[i][0]=i+1
  X[i][1]=x
  X[i][2]=y
C=[int(i) for i in input().split()]
K=[int(i) for i in input().split()]
for i in range(n):
  X[i][3]=C[i]
  X[i][4]=K[i]

ans_am=0
ans_ps=0
Ans=[]
ans_con=0
Con=[]

def m(X):
  ret=0
  cur=X[0][3]
  for i in range(1,len(X)):
    if X[i][3]<cur:
      ret=i
      cur=X[i][3]
  return ret


while X:
  r=m(X)
  ind,x,y,c,k,flag,source=X.pop(r)
  ans_am+=c
  if flag==0:
    ans_ps+=1
    Ans.append(ind)
  else:
    ans_con+=1
    Con.append([ind,source])
  for i in range(len(X)):
    indi,xi,yi,ci,ki,flagi,sourcei=X[i]
    if (k+ki)*(abs(x-xi)+abs(y-yi))<ci:
      X[i][3]=(k+ki)*(abs(x-xi)+abs(y-yi))
      X[i][5]=1
      X[i][6]=ind

print(ans_am)
print(ans_ps)
print(*Ans)
print(ans_con)
for i,j in Con:
  print(i,j)

import sys
input=sys.stdin.readline
n=int(input())
X=[[0]*7 for _ in range(n)]
for i in range(n):
  x,y=map(int,input().split())
  X[i][0],X[i][1],X[i][2]=i+1,x,y
C=[int(i) for i in input().split()]
K=[int(i) for i in input().split()]
for i in range(n):
  X[i][3],X[i][4]=C[i],K[i]

ans_am=0
ans_ps=0
Ans=[]
ans_con=0
Con=[]

def m(X):
  ret=0
  cur=X[0][3]
  for i in range(1,len(X)):
    if X[i][3]<cur:
      ret=i
      cur=X[i][3]
  return ret


while X:
  r=m(X)
  ind,x,y,c,k,flag,source=X.pop(r)
  ans_am+=c
  if flag==0:
    ans_ps+=1
    Ans.append(ind)
  else:
    ans_con+=1
    Con.append((ind,source))
  for i in range(len(X)):
    indi,xi,yi,ci,ki,flagi,sourcei=X[i]
    cost=(k+ki)*(abs(x-xi)+abs(y-yi))
    if cost<ci:
      X[i][3],X[i][5],X[i][6]=cost,1,ind

print(ans_am)
print(ans_ps)
print(*Ans)
print(ans_con)
for i,j in Con:
  print(i,j)

import sys
input=sys.stdin.readline
n=int(input())
X=[[0]*7 for _ in range(n)]
for i in range(n):
  x,y=map(int,input().split())
  X[i][0],X[i][1],X[i][2]=i+1,x,y
C=[int(i) for i in input().split()]
K=[int(i) for i in input().split()]
for i in range(n):
  X[i][3],X[i][4]=C[i],K[i]

ans_am=0
ans_ps=0
Ans=[]
ans_con=0
Con=[]

def m(X):
  ret=0
  cur=X[0][3]
  for i in range(1,len(X)):
    if X[i][3]<cur:
      ret=i
      cur=X[i][3]
  return ret

def cost(k,ki,x,xi,y,yi):
  return (k+ki)*(abs(x-xi)+abs(y-yi))

while X:
  r=m(X)
  ind,x,y,c,k,flag,source=X.pop(r)
  ans_am+=c
  if not flag:
    ans_ps+=1
    Ans.append(ind)
  else:
    ans_con+=1
    Con.append((ind,source))
  for i in range(len(X)):
    indi,xi,yi,ci,ki,flagi,sourcei=X[i]
    co=cost(k,ki,x,xi,y,yi)
    if co<ci:
      X[i][3],X[i][5],X[i][6]=co,1,ind

print(ans_am)
print(ans_ps)
print(*Ans)
print(ans_con)
for i,j in Con:
  print(i,j)

# copy from https://codeforces.com/contest/1245/submission/64023056

N = int(input())  # 市の数
XY = [list(map(int, input().split())) for _ in range(N)]
C = list(map(int, input().split()))  # 市 i に発電所を建てるコスト
K = list(map(int, input().split()))  # つなげるコスト

CC = [-1] * N
Ans = [-2] * N
total_cost = 0
for _ in range(N):
    mi = float("inf")
    for i, (c, an) in enumerate(zip(C, Ans)):
        if an == -2 and mi > c:
            mi = c
            ami = i
    total_cost += mi
    Ans[ami] = CC[ami]
    k1 = K[ami]
    x1, y1 = XY[ami]
    for i, (k2, (x2, y2)) in enumerate(zip(K, XY)):
        new_cost = (k1+k2) * (abs(x1-x2)+abs(y1-y2))
        if C[i] > new_cost:
            C[i] = new_cost
            CC[i] = ami
print(total_cost)
cnt = Ans.count(-1)
print(cnt)
A = []
B = []
for i, a in enumerate(Ans, 1):
    if a==-1:
        A.append(i)
    else:
        B.append((i, a+1))
print(" ".join(map(str, A)))
print(N - cnt)
for a, b in B:
    print(a, b)

n=int(input())
X=[[0]*7 for _ in range(n)]
for i in range(n):
  x,y=map(int,input().split())
  X[i][0]=i+1
  X[i][1]=x
  X[i][2]=y
C=[int(i) for i in input().split()]
K=[int(i) for i in input().split()]
for i in range(n):
  X[i][3]=C[i]
  X[i][4]=K[i]
X.sort(key=lambda x:x[3])
ans_am=0
ans_ps=0
Ans=[]
ans_con=0
Con=[]
 
while X:
  ind,x,y,c,k,flag,source=X.pop(0)
  ans_am+=c
  if flag==0:
    ans_ps+=1
    Ans.append(ind)
  else:
    ans_con+=1
    Con.append([ind,source])
  for i in range(len(X)):
    indi,xi,yi,ci,ki,flagi,sourcei=X[i]
    if (k+ki)*(abs(x-xi)+abs(y-yi))<ci:
      X[i][3]=(k+ki)*(abs(x-xi)+abs(y-yi))
      X[i][5]=1
      X[i][6]=ind
  X.sort(key=lambda x:x[3])
 
print(ans_am)
print(ans_ps)
print(*Ans)
print(ans_con)
for i,j in Con:
  print(i,j)

import math

n = int(input())
cityNo=[0]*n
for i in range(n):
	cityNo[i]=list(map(int,input().split()))
cost=list(map(int,input().split()))
ks  =list(map(int,input().split()))

powerStation=[0]*n

totalCost=0

req_Powerstation=[]
notReq_Powerstation=[]
totalCost=0
established={}
updated=[-1]*n

for j in range(n):

	city=-1
	mini=9999999999999999
	for i in range(n):
		if mini>cost[i] and i not in established:
			city=i
			mini=cost[i]
	if updated[city]==-1:
		req_Powerstation.append(city+1)
	else:
		notReq_Powerstation.append([city+1,updated[city]+1])	
	totalCost+=cost[city]
	established[city]=1

	for i in range(n):

		cost_From_City = (ks[i]+ks[city])*(abs(cityNo[i][0]-cityNo[city][0])+abs(cityNo[i][1]-cityNo[city][1]))
		
		if cost_From_City<cost[i]:
			cost[i]=cost_From_City
			updated[i]=city

		# print(updated)
print(totalCost)
print(len(req_Powerstation))
print(*req_Powerstation)
print(len(notReq_Powerstation))
for i in range(len(notReq_Powerstation)):
	print(*notReq_Powerstation[i])

from sys import stdin,stdout
from collections import Counter
def ai(): return list(map(int, stdin.readline().split()))
def ei(): return map(int, stdin.readline().split())
def ip(): return  int(stdin.readline().strip())
def op(ans): return stdout.write(str(ans) + '\n')

n = ip()
pos = [ai() for i in range(n)]
c = ai()
k = ai()

connections = []
plants = []
used = [False]*n
parent = [-1]*n

ans = 0 
n_ = n
while n_:
	n_ -= 1
	mn , u = min([(ci,i) for i,ci in enumerate(c) if not used[i]])
	ans += mn
	used[u] = True
	if parent[u] == -1:
		plants.append(u)
	else:
		connections.append((min(parent[u],u),max(parent[u],u)))
	for i in range(n):
		con_cost = (k[u]+k[i])*(abs(pos[u][0]-pos[i][0])+abs(pos[u][1]-pos[i][1]))
		if con_cost < c[i]:
			c[i] = con_cost
			parent[i] = u
print(ans)
print(len(plants))
for i in sorted(plants):
	print(i+1,end=' ')
print()
print(len(connections))
for i in connections:
	print(i[0]+1,i[1]+1)



def dist(a,b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])
n = int(input())
p = []
for i in range(n):
    p.append(list(map(int, input().split())))
c = list(map(int, input().split()))
k = list(map(int, input().split()))
st = []
ed = []
ans = 0
is_st = [1] * n
parent = [-1] * n
d = { i:  c[i] for i in range(n)}
for i in range(n):
    m = min(d, key = d.get)
    if(is_st[m]):
        st.append(m)
    else:
        ed.append([m, parent[m]])
    ans = ans + d[m]
    del d[m]
    for j in d.keys():
        t_cost = (k[m] + k[j])*dist(p[m], p[j])
        if(t_cost < d[j]):
            d[j] = t_cost
            parent[j] = m
            is_st[j] = 0
print(ans)
print(len(st))
for i in st:
    print(i+1,end = " ")
print()
print(len(ed))
for i in ed:
    print(i[0]+1,i[1]+1)


import sys
#import heapq as hq
#from collections import deque
#sys.stdin = open('in', 'r')
readline = sys.stdin.readline
rdw = lambda: readline().rstrip()
rdws = lambda: readline().split()
rdwl = lambda: list(readline().split())
rdi = lambda: int(readline())
rdis = lambda: list(map(int, readline().split()))
rdil = lambda: list(map(int, readline().split()))
rdilrows = lambda cnt: [rdil() for _ in range(cnt)]

def solve():
    res = 0
    bld = []
    wire = []
    n = rdi()
    cities = rdilrows(n)
    c = rdil()
    p = [-1 for i in range(n)]
    k = rdil()
    used = set()
    used.add(-1)
    
    for i in range(n):
        cost, bst = min([(c[i], i) for i in range(n) if i not in used])
        par = p[bst]
        used.add(bst)
        res += cost
        if par == -1:
            bld.append(bst + 1)
        else:
            wire.append((bst + 1, par + 1))
        for j in range(n):
            if j not in used:
                wcost = (k[bst]+k[j])*(abs(cities[bst][0]-cities[j][0]) \
                                    + abs(cities[bst][1]-cities[j][1]))
                if wcost < c[j]:
                    c[j] = wcost
                    p[j] = bst
    
    sys.stdout.write(f'{res}\n')
    sys.stdout.write(f'{len(bld)}\n')
    sys.stdout.write(f'{" ".join(map(str, bld))}\n')
    sys.stdout.write(f'{len(wire)}\n')
    for i in range(len(wire)):
        sys.stdout.write(f'{wire[i][0]} {wire[i][1]}\n')


tests = 1
#tests = rdi()
for testnum in range(tests):
    solve()
    
#n = rdi()
#n,m = rdis()
#s = rdw()
#a = rdil()
#op, *s = rdws()

#print(f'Case #{testnum+1}: {res}')
#print(*res, sep='\n')
#sys.stdout.write('YES\n')
#sys.stdout.write(f'{res}\n')
#sys.stdout.write(f'{y1} {x1} {y2} {x2}\n')