import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in=new Scanner(System.in); ArrayListlist=new ArrayList(); int magic1[][]={{8,1,6},{3,5,7},{4,9,2}}; list.add(magic1); int magic2[][]={{6,1,8},{7,5,3},{2,9,4}}; list.add(magic2); int magic3[][]={{4,9,2},{3,5,7},{8,1,6}}; list.add(magic3); int magic4[][]={{2,9,4},{7,5,3},{6,1,8}}; list.add(magic4); int magic5[][]={{8,3,4},{1,5,9},{6,7,2}}; list.add(magic5); int magic6[][]={{4,3,8},{9,5,1},{2,7,6}}; list.add(magic6); int magic7[][]={{6,7,2},{1,5,9},{8,3,4}}; list.add(magic7); int magic8[][]={{2,7,6},{9,5,1},{4,3,8}}; list.add(magic8); int magic[][]=new int[3][3]; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ magic[i][j]=in.nextInt(); } } int lowestCost=Integer.MAX_VALUE; for(int i=0;i