Under construction

Still being built. Things may change

Network Saboteur

Time limit1sMemory limit128 MB

Summary
Split N nodes (N <= 20) into two sets A and B so the total weight of edges crossing between them is maximized.
Level

Medium5 of 10

Topics
Brute force, Backtracking, Implementation
Solved
No attempts yet

Problem

A university network consists of NN computers. The system administrators measured the traffic between every pair of nodes and split the network into two subnetworks so that the traffic flowing between the two parts is as small as possible.

A disgruntled student, Vasya, who was expelled from the university, wants to do the opposite. He has taken control of the network and wants to reassign the computers so that the traffic between the two subnetworks is as large as possible. Computing this worst-case split is a problem he cannot solve, so he asks you for help.

The traffic is given as a matrix CC, where CijC_{ij} is the amount of data exchanged between node ii and node jj. The matrix is symmetric (Cij=CjiC_{ij} = C_{ji}) and has no self-traffic (Cii=0C_{ii} = 0). Partition the NN nodes into two disjoint sets AA and BB so as to maximize

∑i∈A,  j∈BCij.\sum_{i \in A,\; j \in B} C_{ij}.

Input

The first line contains the number of nodes NN (2≤N≤202 \le N \le 20).

Each of the following NN lines contains NN space-separated integers; the jj-th integer on the ii-th line is CijC_{ij} (0≤Cij≤100000 \le C_{ij} \le 10000). The matrix is symmetric with a zero diagonal.

Output

Print a single integer — the maximum possible traffic between the two subnetworks.

Examples4

  1. Example 1

    Input
    3
    0 50 30
    50 0 40
    30 40 0
    
    Expected output
    90
    
  2. Example 2

    Input
    2
    0 100
    100 0
    
    Expected output
    100
    
  3. Example 3

    Input
    4
    0 1 1 1
    1 0 1 1
    1 1 0 1
    1 1 1 0
    
    Expected output
    4
    
  4. Example 4

    Input
    5
    0 3 1 4 1
    3 0 5 9 2
    1 5 0 6 5
    4 9 6 0 3
    1 2 5 3 0
    
    Expected output
    27