This is an approximate probem.
Given an undirected complete graph G with n vertices. The weight of the edge between (i,j) is equal to C[i][j]. Let D(i,j) be the shortest distance between vertices i,j and W(G) be the sum of all shortest distances between any two vertices. You can remove at most k edges from graph G in order to obtain a graph G'. You have to maximize the ratio of the sum of all shortest distances between any two vertices in new graph G' (after removing the edges) and sum of all shortest distances between any two vertices in old graph G (before reomoving the edges): W(G′)W(G). G must remain connected.
Input
The first line contains two space separated integers n (n=128) and k (0≤k≤(n−1)2) denoting the number of vertices and at most how many edges you can remove.
Next n lines contains n space separated integers. ith line denotes the elements of C[i] i.e.
C[i][1],C[i][2],…,C[i][n] (C[i][i]=0,C[i][j]=C[j][i],1≤C[i][j]≤220).
Output
The first line contains a number q (0≤q≤k) - the number of edges deleted.
Next q lines contains two space separated integers each, xi,yi (1≤xi<yi≤n) denoting that edge (xi,yi) will be deleted.
Scoring
The score will be equal to W(G′)W(G).
Tests
The value k will be taken uniformly from interval [0,(n−1)2].
The value C[i][j] (1≤i<j≤n) will be taken uniformly from interval [1,220].
We delete vertex (1,2) and obtain that D(1,2)=2, D(2,3)=1 and D(1,3)=1 so the total sum is equal to D(1,2)+D(2,1)+D(2,3)+D(3,2)+D(1,3)+D(3,1)=2(D(1,2)+D(2,3)+D(3,1))=2(2+1+1)=8.