output_description: Print the minimum total weight of the edges in such a cycle.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 B_1
      A_2 B_2
      :
      A_N B_N
attempt: 4
  1 5
  2 6
  3 7
  4 8
  
problem_description: Statement
  
  We have a directed weighted graph with N vertices. Each vertex has two
  integers written on it, and the integers written on Vertex i are A_i and B_i.
  
  In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq
  x,y \leq N, and its weight is {\rm min}(A_x,B_y).
  
  We will consider a directed cycle in this graph that visits every vertex
  exactly once. Find the minimum total weight of the edges in such a cycle.
samples: [{"input": "3\n    1 5\n    4 2\n    6 3", "output": "7\n    \n\nConsider the cycle 1\u21923\u21922\u21921. The weights of those edges are {\\rm\nmin}(A_1,B_3)=1, {\\rm min}(A_3,B_2)=2 and {\\rm min}(A_2,B_1)=4, for a total of\n7. As there is no cycle with a total weight of less than 7, the answer is 7.\n\n* * *"}, {"input": "4\n    1 5\n    2 6\n    3 7\n    4 8", "output": "10\n    \n\n* * *"}, {"input": "6\n    19 92\n    64 64\n    78 48\n    57 33\n    73 6\n    95 73", "output": "227"}]