using System;
using System.Collections.Generic;

using System.Text;

namespace e_olimp
{
    class Program
    {
        static int[] parseInt(string s)
        {
            string[] temp = s.Split(' ');
            List<int> res = new List<int>();
            for (int i = 0; i < temp.Length; i++)
            {
                res.Add(Convert.ToInt32(temp[i]));
            }
            return res.ToArray();
        }

        static int round(double a)
        {
            a *= 100000000000;
            long res = (long)a;
            for (int i = 0; i < 11; i++)
            {
                if (res % 10 > 4)
                {
                    res /= 10;
                    res++;
                }
                else
                    res /= 10;
            }
            return (int)res;
        }
        static void Main(string[] args)
        {
            bool tf = true;
            int[,] A = new int[3, 3];
            for (int i = 0; i < 3; i++)
            {
                int[] p = parseInt(Console.ReadLine());
                for (int j = 0; j < 3; j++)
                {
                    A[i, j] = p[j];
                }
            }

            int sum = A[1, 0] + A[1, 2];

            for (int i = 0; sum - i >= 0; i++)
            {
                int tmp11 = i + A[0, 1] + A[0, 2];
                int tmp12 = i + A[1, 0] + A[2, 0];
                int tmp21 = sum - i + A[2, 0] + A[2, 1];
                int tmp22 = sum - i + A[0, 2] + A[1, 2];
                if (tmp11 == tmp12 && tmp12 == tmp21 && tmp21 == tmp22)
                {
                    int res = tmp22 - sum;
                    A[0, 0] = i;
                    A[2, 2] = sum - i;
                    A[1, 1] = res;
                    for (int k = 0; k < 3; k++)
                    {
                        for (int z = 0; z < 3; z++)
                        {
                            Console.Write(A[k,z]);
                            if(z < 2)
                                Console.Write(" ");
                        }
                        Console.WriteLine();
                    }
                    return;
                }
            }
        }
    }
}

using System;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[][] matrix = new int[3][];
            int[] s = new int[3];

            for (int i = 0; i < 3; i++)
            {
                matrix[i] = new int[3];
                s[i] = 0;

                string[] lineParts = Console.ReadLine().Split(' ');

                for (int j = 0; j < 3; j++)
                {
                    matrix[i][j] = int.Parse(lineParts[j]);
                    s[i] += matrix[i][j];
                }
            }

            int max = Math.Max(s[0], Math.Max(s[1], s[2]));

            matrix[0][0] = max - matrix[0][1] - matrix[0][2] + 1;
            matrix[1][1] = max - matrix[1][0] - matrix[1][2] + 1;
            matrix[2][2] = max - matrix[2][0] - matrix[2][1] + 1;

            int diff = (max + 1 - matrix[0][0] - matrix[1][1] - matrix[2][2]) / 2;

            for (int i = 0; i < 3; i++)
            {
                matrix[i][i] += diff;
                Console.WriteLine(matrix[i][0] + " " + matrix[i][1] + " " + matrix[i][2]);
            }
        }
    }
}

using System;
using System.Linq;
class Test{
    static void Main(){
        int [, ] a = new int [3, 3];
        int [] r = new int[3];
        int [] d = new int[3];
        for(int i = 0; i < 3; i++){
            string [] line = Console.ReadLine().Split();
            a[i, 0] = int.Parse(line[0]);
            a[i, 1] = int.Parse(line[1]);
            a[i, 2] = int.Parse(line[2]);
            r[i] = a[i, 0] + a[i, 1] + a[i, 2];
        }
        int x = 0;
        int r_ref = r[0];

        int r_max = r.Max();
        int sum_r = 0;

        for(int k = 0; k < 3; k++){
            r[k] = r_max - r[k];
            sum_r += r[k];
        }

        r_ref += r[0];

        while(true){
            if(sum_r == r_ref){
                break;
            }
            sum_r += 3;
            r_ref++;
            x++;
        }

        for(int j = 0; j < 3; j++){
            a[j, j] += r[j] + x;
            Console.WriteLine("{0} {1} {2}", a[j, 0], a[j, 1], a[j, 2]);
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace CodeForces
{
	internal class Template
	{
		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
			//Console.SetIn(new StreamReader(@"C:\CodeForces\input.txt"));
			new Template().Solve();
		}

		private void Solve()
		{
			var magic = new int[3,3];
			for (var i =0; i < 3; i++)
			{
				for (var j = 0; j < 3; j++)
				{
					magic[i, j] = cin.NextInt();
				}
			}
			for (var a = 0; a < 100005; a++)
			{
				var sum = a + magic[1, 0] + magic[2, 0];
				var mid = sum - magic[1, 0] - magic[1, 2];
				var bot = sum - magic[2, 0] - magic[2, 1];
				if (sum == a + mid + bot)
				{
					magic[0, 0] = a;
					magic[1, 1] = mid;
					magic[2, 2] = bot;
					for (var i = 0; i < 3; i++)
					{
						for (var j = 0; j < 3; j++)
						{
							if (j > 0)
							{
								Console.Write(" ");
							}
							Console.Write(magic[i, j]);
						}
						Console.WriteLine();
					}
				}
			}
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = new[] { ' ' };

		public string Next()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}
	}
}

using System;
using System.Linq;

namespace CSharp
{
    public class _259B
    {
        public static void Main()
        {
            int[][] square = new int[3][];
            int totalSum = 0;

            for (int i = 0; i < 3; i++)
            {
                square[i] = Console.ReadLine().Split().Select(token => int.Parse(token)).ToArray();
                totalSum += square[i].Sum();
            }

            square[0][0] = totalSum / 2 - square[0].Sum();
            square[1][1] = totalSum / 2 - square[1].Sum();
            square[2][2] = totalSum / 2 - square[2].Sum();

            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(string.Join(" ", square[i]));
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace cf157
{
    class B
    {
        static int[,] mat = new int[3, 3];

        static bool check(int sum)
        {
            if (mat[1, 0] + mat[1, 1] + mat[1, 2] != sum)
                return false;
            if (mat[0, 0] + mat[1, 1] + mat[2, 2] != sum)
                return false;
            if (mat[2, 0] + mat[1, 1] + mat[0, 2] != sum)
                return false;
            if (mat[2, 0] + mat[2, 1] + mat[2, 2] != sum)
                return false;
            return true;
        }

        static void Main(string[] args)
        {
            for (int i = 0; i < 3; i++)
            {
                string[] s = Console.ReadLine().Split();
                for (int j = 0; j < 3; j++)
                {
                    mat[i, j] = int.Parse(s[j]);
                }
            }
            for (int i = 1; i <= 100000; i++)
            {
                mat[0,0]=i;
                int sum = i + mat[1, 0] + mat[2, 0];
                mat[1, 1] = sum - mat[0, 1] - mat[2, 1];
                mat[2, 2] = sum - mat[0, 2] - mat[1, 2];
                if (check(sum))
                {
                    for (int k = 0; k < 3; k++)
                    {
                        Console.WriteLine(mat[k,0]+" "+mat[k,1]+" "+mat[k,2]);
                    }
                    break;
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace Codeforces
{
    internal static class Program
    {
        private const string test = "A1";

        private static void Solve()
        {
            var a = ReadIntArray();
            var b = ReadIntArray();
            var c = ReadIntArray();
            var aSum = a.Sum();
            var bSum = b.Sum();
            var cSum = c.Sum();
            var v1Sum = a[0] + b[0] + c[0];
            var v2Sum = a[1] + b[1] + c[1];
            var v3Sum = a[2] + b[2] + c[2];
            var d2Sum = a[2] + b[1] + c[0];
            for (int a0 = 1; a0 <= 100000; a0++)
            {
                var b1 = aSum + a0 - bSum;
                var c2 = aSum + a0 - cSum;
                if (b1 > 0 && b1 <= 100000 && c2 > 0 && c2 <= 100000)
                {
                    if (v1Sum + a0 == v2Sum + b1 && v1Sum + a0 == v3Sum + c2
                        && v1Sum +a0 == aSum + a0)
                    {
                        if (aSum + a0 == a0 + b1 + c2 &&
                            aSum + a0 == d2Sum + b1)
                        {
                            WriteLine(a0 + " " + a[1] + " " + a[2] );
                            WriteLine(b[0] + " " + b1 + " " + b[2]);
                            WriteLine(c[0] + " " + c[1] + " " + c2);
                            return;
                        }
                    }
                }
            }
        }

        private static void Main()
        {
            if (Debugger.IsAttached)
            {
                Console.SetIn(new StreamReader(String.Format(@"..\..\..\..\Tests\{0}.in", test)));
            }

            Solve();

            if (Debugger.IsAttached)
            {
                Console.In.Close();
                Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                Console.ReadLine();
            }
        }

        #region Reader

        private static string Read()
        {
            return Console.ReadLine();
        }

        private static void Read(out int n1, out int n2)
        {
            var input = ReadArray();
            n1 = int.Parse(input[0]);
            n2 = int.Parse(input[1]);
        }
        private static void Read(out int n1, out int n2, out int n3)
        {
            var input = ReadArray();
            n1 = int.Parse(input[0]);
            n2 = int.Parse(input[1]);
            n3 = int.Parse(input[2]);
        }
        private static void Read(out int n1, out int n2, out int n3, out int n4)
        {
            var input = ReadArray();
            n1 = int.Parse(input[0]);
            n2 = int.Parse(input[1]);
            n3 = int.Parse(input[2]);
            n4 = int.Parse(input[3]);
        }

        private static void Read<T>(out T a1, out T a2)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
        }

        private static int ReadInt()
        {
            return Int32.Parse(Read());
        }

        private static long ReadLong()
        {
            return long.Parse(Read());
        }

        private static double ReadDouble()
        {
            return double.Parse(Read(), CultureInfo.InvariantCulture);
        }

        private static T Read<T>()
        {
            return (T)Convert.ChangeType(Read(), typeof(T));
        }

        private static string[] ReadArray()
        {
            var readLine = Console.ReadLine();
            if (readLine != null)
                return readLine.Split(' ');

            throw new ArgumentException();
        }

        private static List<int> ReadIntArray()
        {
            return ReadArray().Select(Int32.Parse).ToList();
        }

        private static List<long> ReadLongArray()
        {
            return ReadArray().Select(long.Parse).ToList();
        }

        private static List<double> ReadDoubleArray()
        {
            return ReadArray().Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();
        }

        private static List<T> ReadArray<T>()
        {
            return ReadArray().Select(x => (T) Convert.ChangeType(x, typeof (T))).ToList();
        }

        private static void WriteLine(int value)
        {
            Console.WriteLine(value);
        }

        private static void WriteLine(double value)
        {
            Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void WriteLine(long value)
        {
            Console.WriteLine(value);
        }

        private static void WriteLine(double value, string stringFormat)
        {
            Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void WriteLine<T>(T value)
        {
            Console.WriteLine(value);
        }

        private static void Write(int value)
        {
            Console.Write(value);
        }

        private static void Write(double value)
        {
            Console.Write(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void Write(long value)
        {
            Console.Write(value);
        }

        private static void Write(double value, string stringFormat)
        {
            Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void Write<T>(T value)
        {
            Console.Write(value);
        }

        #endregion
    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] mas = s.Split(' ');
            int a=int.Parse(mas[0]);
            int b=int.Parse(mas[1]);
            int c = int.Parse(mas[2]);
            s = Console.ReadLine();
            mas = s.Split(' ');
            int d = int.Parse(mas[0]);
            int e = int.Parse(mas[1]);
            int f = int.Parse(mas[2]);
            s = Console.ReadLine();
            mas = s.Split(' ');
            int g = int.Parse(mas[0]);
            int h = int.Parse(mas[1]);
            int i = int.Parse(mas[2]);
            e = (h + b) / 2;
            i = (b + 2 * c - h) / 2;
            a = e + f - g;
            Console.WriteLine("{0} {1} {2}", a, b, c);
            Console.WriteLine("{0} {1} {2}", d, e, f);
            Console.WriteLine("{0} {1} {2}", g, h, i);
        }
    }
}

using System;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] matr = new int[3,3];

            for (int i = 0; i < 3; i++)
            {
                int j = 0;
                foreach (string s in Console.ReadLine().Split(' '))
                {
                    matr[i, j] = Convert.ToInt32(s);
                    j++;
                }
            }

            matr[1, 1] = (3*matr[0, 2] + matr[2, 0] - matr[1, 0] - matr[2, 1])/2;
            int sum = matr[1, 0] + matr[1, 1] + matr[1, 2];

            matr[0, 0] = sum - matr[0, 1] - matr[0, 2];
            matr[2, 2] = sum - matr[2, 0] - matr[2, 1];

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Console.Write(matr[i,j]+" ");
                }

                Console.WriteLine();
            }
        }
    }
}

using System;
using System.Text;

namespace codeforces_round_157_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] arr = new int[3,3];
            int sum = 0;
            int sum2 = 0;
            for (int i = 0; i < 3; i++)
            {
                string[] st = Console.ReadLine().Split(' ');
                for (int j = 0; j < 3; j++)
                {
                    arr[i, j] = Int32.Parse(st[j]);
                    sum += arr[i, j];
                }
            }
            sum /= 2;
            arr[0,0] = sum - (arr[0, 1] + arr[0, 2]);
            arr[2, 2] = sum - (arr[0, 2] + arr[1, 2]);
            arr[1, 1] = (arr[0, 0] + arr[2, 2])/2;
            int x = 0;
            foreach (int i in arr)
            {
                if (x++ < 2)
                    Console.Write(i+" ");
                else
                {
                    Console.WriteLine(i);
                    x = 0;
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication12_a
{
    class Program
    {
        static void Main(string[] args)
        {

            int[,] a = new int[3, 3];
            string[] data=new string[3];
            for (int i = 0; i < 3; i++)
            {
                data = Console.ReadLine().Split(' ');
                a[i, 0] = int.Parse(data[0]);
                a[i, 1] = int.Parse(data[1]);
                a[i, 2] = int.Parse(data[2]);
            }

            a[0, 0] = (a[1, 2] + a[2, 1]) / 2;
            a[1, 1] = (a[0, 2] + a[2, 0]) / 2;
            a[2, 2] = (a[1, 0] + a[0, 1]) / 2;

            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(a[i, 0] + " " + a[i, 1] + " " + a[i, 2]);
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Little_Elephant_and_Magic_Square
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] magic = new int[3, 3];
            for (int i = 0; i < 3; i++)
            {
                string[] s = Console.ReadLine().Split();
                for (int j = 0; j < 3; j++)
                {
                    magic[i, j] = Int32.Parse(s[j]);
                }
            }
            magic[0, 0] = (-magic[0, 1] - magic[0, 2] + magic[1, 0] + magic[1, 2] + magic[2, 0] + magic[2, 1]) / 2;
            magic[1, 1] = (magic[0, 1] + magic[0, 2] - magic[1, 0] - magic[1, 2] + magic[2, 0] + magic[2, 1]) / 2;
            magic[2, 2] = (magic[0, 1] + magic[0, 2] + magic[1, 0] + magic[1, 2] - magic[2, 0] - magic[2, 1]) / 2;
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Console.Write(magic[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}

using System;

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
          //  Console.SetIn(System.IO.File.OpenText("input.txt"));

            int[,] input = new int[3, 3];
            for (int row = 0; row < 3; row++)
            {
                string[] sRow = Console.ReadLine().Split();
                for (int column = 0; column < 3; column++)
                    input[row, column] = int.Parse(sRow[column]);
            }

            int x1 = input[0, 1] + input[0, 2];
            int x2 = input[1, 0] + input[1, 2];
            int x3 = input[2, 0] + input[2, 1];
            int max = Math.Max(Math.Max(x1, x2), x3) + 1;

            int r1 = max - x1;
            int r2 = max - x2;
            int r3 = max - x3;

            int lsum = r1 + r2 + r3;

            int x = (max - lsum) / 2;
            input[0, 0] = r1 + x;
            input[1, 1] = r2 + x;
            input[2, 2] = r3 + x;

            for (int row = 0; row < 3; row++)
            {
                string sRow = Console.ReadLine();
                for (int column = 0; column < 3; column++)
                {
                    if(column != 2)
                        Console.Write(input[row, column].ToString() + " ");
                    else
                        Console.Write(input[row, column].ToString());
                }
                Console.WriteLine("\r\n");
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeForces
{
    class Program_R157_Div2_B
    {
        static void Main(string[] args)
        {
            int[] a = new int[10];
            int sum;
            for (int i = 0; i < 3; i++)
            {
                string[] s = (Console.ReadLine().Split());
                a[i * 3 + 1] = Convert.ToInt32(s[0]);
                a[i * 3 + 2] = Convert.ToInt32(s[1]);
                a[i * 3 + 3] = Convert.ToInt32(s[2]);
            }

            for (int i = 1; i <= 100000; i++)
            {
                a[5] = i;
                sum = a[4] + a[5] + a[6];
                if (sum == a[2] + a[5] + a[8]
                    && sum == a[3] + a[5] + a[7])
                {
                    a[1] = sum - a[2] - a[3];
                    a[9] = sum - a[7] - a[8];
                    if (sum == a[1] + a[4] + a[7]
                        && sum == a[3] + a[6] + a[9]
                        && sum == a[1] + a[5] + a[9])
                        break;
                }
            }

            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine("{0} {1} {2}", a[i * 3 + 1], a[i * 3 + 2], a[i * 3 + 3]);
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Coderandom
{
    class Program
    {
        static void Print(int[,] m,int[]a)
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (i==j)
                    {
                        Console.Write(a[i]+" ");
                    }
                    else
                    {
                        Console.Write(m[i,j]+" ");
                    }
                }
                Console.WriteLine();
            }
        }
        static void Main(string[] args)
        {
            int[,] matrix = new int[3, 3];
            int [] mas = new int[3];
            int[]ind = new int[3];
            for (int i = 0; i < 3; i++)
            {
                string[] ss = Console.ReadLine().Split(' ');

                for (int j = 0; j < 3; j++)
                {
                    matrix[i, j] = int.Parse(ss[j]);
                    mas[i] += matrix[i, j];
                }
            }

            for (int i = 0; i < 100001; i++)
            {
                ind[0] = i ;
                ind[1] = mas[0]+i - mas[1];
                ind[2] = mas[0] + i - mas[2];

                if(ind[0]+ind[2]+ind[1]==i+mas[0]) break;
            }

            Print(matrix,ind);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace souomoun
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            string c = Console.ReadLine();
            int[] la = new int[3];
            int[] lb = new int[3];
            int[] lc = new int[3];
            la[0] = int.Parse(a.Split(' ')[0]);
            la[1] = int.Parse(a.Split(' ')[1]);
            la[2] = int.Parse(a.Split(' ')[2]);
            lb[0] = int.Parse(b.Split(' ')[0]);
            lb[1] = int.Parse(b.Split(' ')[1]);
            lb[2] = int.Parse(b.Split(' ')[2]);
            lc[0] = int.Parse(c.Split(' ')[0]);
            lc[1] = int.Parse(c.Split(' ')[1]);
            lc[2] = int.Parse(c.Split(' ')[2]);
            int k = 0;
            for (; ; )
            {
                int aa = la[1] + lb[2];
                if (la[1] == 0 || lb[2] == 0) { aa = -1; }
                int ab = lc[1] + lb[2];
                if (lc[1] == 0 || lb[2] == 0) { ab = -1; }
                int ac = lc[1] + lb[0];
                if (lc[1] == 0 || lb[0] == 0) { ac = -1; }
                int ad = la[1] + lb[0];
                if (la[1] == 0 || lb[0] == 0) { ad = -1; }
                int aa2 = lc[0];
                int ab2 = la[0];
                int ac2 = la[2];
                int ad2 = lc[2];
                if (aa2 == 0 && aa != -1) { lc[0] = aa / 2; }
                if (ab2 == 0 && ab != -1) { la[0] = ab / 2; }
                if (ac2 == 0 && ac != -1) { la[2] = ac / 2; }
                if (ad2 == 0 && ad != -1) { lc[2] = ad / 2; }
                int az = 0;
                int bz = 0;
                int cz = 0;
                int dz = 0;
                if (la[1] == 0) { az++; dz++; }
                if (lb[0] == 0) { cz++; dz++; }
                if (lb[2] == 0) { az++; bz++; }
                if (lc[1] == 0) { bz++; cz++; }
                if (az == 1 && aa2 != 0) { if (la[1] == 0) { la[1] = aa2 * 2 - lb[2]; } if (lb[2] == 0) { lb[2] = aa2 * 2 - la[1]; } }
                if (bz == 1 && ab2 != 0) { if (lc[1] == 0) { lc[1] = ab2 * 2 - lb[2]; } if (lb[2] == 0) { lb[2] = ab2 * 2 - lc[1]; } }
                if (cz == 1 && ac2 != 0) { if (lc[1] == 0) { lc[1] = ac2 * 2 - lb[0]; } if (lb[0] == 0) { lb[0] = ac2 * 2 - lc[1]; } }
                if (dz == 1 && ad2 != 0) { if (la[1] == 0) { la[1] = ad2 * 2 - lb[0]; } if (lb[0] == 0) { lb[0] = ad2 * 2 - la[1]; } }
                k++;
                if (k == 3) { break; }
            }
            if (lb[1] == 0) { lb[1] = la[0] + la[1] + la[2] - lb[0] - lb[2]; }
            Console.WriteLine("" + la[0] + " " + la[1] + " " + la[2] + "");
            Console.WriteLine("" + lb[0] + " " + lb[1] + " " + lb[2] + "");
            Console.WriteLine("" + lc[0] + " " + lc[1] + " " + lc[2] + "");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CDF157
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] a = new int[3, 3];
            string[] input;
            for (int i = 0; i < 3; i++)
            {
                input = Console.ReadLine().Split(' ');
                for (int j = 0; j < 3; j++)
                    a[i, j] = int.Parse(input[j]);
            }
            int e = (a[0, 1] + a[0, 2] + a[1, 0] + a[1, 2] + a[2, 0] + a[2, 1]) / 2;
            a[0,0] = e - a[0, 1] - a[0, 2];
            a[1,1]= e - a[1, 0] - a[1, 2];
            a[2,2] = e - a[2, 0] - a[2, 1];
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                    Console.Write(a[i, j] + " ");
                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace Codeforces
{
    class B
    {
        private static ThreadStart s_threadStart = new B().Go;
        private static bool s_time = false;

        private void Go()
        {
            List<List<int>> data = new List<List<int>>();
            data.Add(GetIntArr(3));
            data.Add(GetIntArr(3));
            data.Add(GetIntArr(3));

            int A = data[0][1] + data[0][2];
            int B = data[0][2] + data[2][0];
            int C = data[2][0] + data[2][1];

            data[0][0] = (B + C - A) / 2;
            data[1][1] = (A + C - B) / 2;
            data[2][2] = (A + B - C) / 2;

            for(int i = 0; i< 3;i++)
            Wl(data[i][0]+" "+data[i][1]+" "+data[i][2]);
        }

        #region Template

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            Thread main = new Thread(new ThreadStart(s_threadStart), 200 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            timer.Stop();
            if (s_time)
                Wl(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            while (ioEnum == null || !ioEnum.MoveNext())
            {
                ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
            }

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            if (o is double)
            {
                Wld((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wld((o as float?).Value, "");
            }
            else
                Console.WriteLine(o.ToString());
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            Wl(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wld(double d, string format)
        {
            Wl(d.ToString(format, CultureInfo.InvariantCulture));
        }

        public struct Tuple<T, K> : IComparable<Tuple<T, K>>
            where T : IComparable<T>
            where K : IComparable<K>
        {
            public T Item1;
            public K Item2;

            public Tuple(T t, K k)
            {
                Item1 = t;
                Item2 = k;
            }

            public override bool Equals(object obj)
            {
                var o = (Tuple<T, K>)obj;
                return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);
            }

            public override int GetHashCode()
            {
                return Item1.GetHashCode() ^ Item2.GetHashCode();
            }

            public override string ToString()
            {
                return "(" + Item1 + " " + Item2 + ")";
            }

            #region IComparable<Tuple<T,K>> Members

            public int CompareTo(Tuple<T, K> other)
            {
                int ret = Item1.CompareTo(other.Item1);
                if (ret != 0) return ret;
                return Item2.CompareTo(other.Item2);
            }

            #endregion
        }

        #endregion
    }
}

using System.Text;
using System;
namespace CodeForces {
    public class Round157ProblemB {
        public const int INPUT_SIZE = 3;

        public static void Main(String[] args) {
            // Console.WriteLine("20, 30, 10, 30, 20, 10");
            // int[] cards = new int[] {20, 30, 10, 30, 20, 10};
            // string[] pairs = Problem254A.GetPairs(cards);
            // foreach (string pair in pairs) {
            //     Console.WriteLine(pair);
            // }

            // Console.WriteLine("1, 2");
            // cards = new int[] {1, 2};
            // pairs = Problem254A.GetPairs(cards);
            // foreach (string pair in pairs) {
            //     Console.WriteLine(pair);
            // }

            Round157ProblemB p = new Round157ProblemB();
            int[,] input = p.GetInput();

            p.GetOutput(ref input);

            p.PrintOutput(input);
        }

        public int[,] GetInput() {
            int[,] input = new int[INPUT_SIZE,INPUT_SIZE];
            int i = 0;
            while (i < INPUT_SIZE) {
                string[] strs = Console.ReadLine().Split(' ');
                for (int j = 0; j < INPUT_SIZE; j++) {
                    input[i,j] = int.Parse(strs[j]);
                }

                i++;
            }

            return input;
        }

        public void GetOutput(ref int[,] input) {
            int s1 = input[0,1] + input[0,2];
            int s2 = input[1,0] + input[1,2];
            int s3 = input[2,0] + input[2,1];
            while (true) {
                int sum = s1 + input[0,0];
                int input11 = sum - s2;
                if (input[0,0] + input11 == s3) {
                    input[1,1] = input11;
                    input[2,2] = sum - s3;
                    return;
                }
                else {
                    input[0,0]++;
                }
            }
        }

        public void PrintOutput(int[,] input) {
            StringBuilder sb = new StringBuilder();
            int count = 1;
            foreach (int i in input) {
                sb.Append(i);
                if (count % 3 == 0) {
                    sb.Append(Environment.NewLine);
                    count = 1;
                }
                else {
                    sb.Append(" ");
                    count++;
                }
            }

            Console.WriteLine(sb.ToString());
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace Temp
{
    internal class PointInt
    {
        public long X;

        public long Y;

        public PointInt(long x, long y)
        {
            this.X = x;
            this.Y = y;
        }

        public PointInt(PointInt head)
            : this(head.X, head.Y)
        {
        }

        public static PointInt operator +(PointInt a, PointInt b)
        {
            return new PointInt(a.X + b.X, a.Y + b.Y);
        }

        public static PointInt operator -(PointInt a, PointInt b)
        {
            return new PointInt(a.X - b.X, a.Y - b.Y);
        }

        public static PointInt operator *(PointInt a, long k)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public static PointInt operator *(long k, PointInt a)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public bool IsInsideRectangle(long l, long b, long r, long t)
        {
            return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);
        }

        public bool Equals(PointInt other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }
            if (ReferenceEquals(this, other))
            {
                return true;
            }
            return other.X == this.X && other.Y == this.Y;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }
            if (ReferenceEquals(this, obj))
            {
                return true;
            }
            if (obj.GetType() != typeof(PointInt))
            {
                return false;
            }
            return Equals((PointInt)obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (this.X.GetHashCode() * 397) ^ this.Y.GetHashCode();
            }
        }
    }

    internal class LineInt
    {
        public LineInt(PointInt a, PointInt b)
        {
            A = a.Y - b.Y;
            B = b.X - a.X;
            C = a.X * b.Y - a.Y * b.X;
        }

        public long A, B, C;

        public bool ContainsPoint(PointInt p)
        {
            return A * p.X + B * p.Y + C == 0;
        }

        public int Sign(PointInt p)
        {
            return Math.Sign(A * p.X + B * p.Y + C);
        }
    }

    internal static class Geometry
    {
        public static long VectInt(PointInt a, PointInt b)
        {
            return a.X * b.Y - a.Y * b.X;
        }

        public static long VectInt(PointInt a, PointInt b, PointInt c)
        {
            return (b.X - a.X) * (c.Y - a.Y) - (b.Y - a.Y) * (c.X - a.X);
        }
    }

    internal class MatrixInt
    {
        private readonly long[,] m_Matrix;

        public int Size
        {
            get
            {
                return m_Matrix.GetLength(0);
            }
        }

        public long Mod { get; private set; }

        public MatrixInt(int size, long mod = 0)
        {
            m_Matrix = new long[size,size];
            Mod = mod;
        }

        public MatrixInt(long[,] matrix, long mod = 0)
        {
            this.m_Matrix = matrix;
            Mod = mod;

            for (int i = 0; i < Size; i++)
            {
                for (int j = 0; j < Size; j++)
                {
                    m_Matrix[i, j] %= mod;
                }
            }
        }

        public static MatrixInt GetIdentityMatrix(int size, long mod = 0)
        {
            long[,] matrix = new long[size,size];

            for (int i = 0; i < size; i++)
            {
                matrix[i, i] = 1;
            }

            return new MatrixInt(matrix, mod);
        }

        public long this[int i, int j]
        {
            get
            {
                return m_Matrix[i, j];
            }

            set
            {
                m_Matrix[i, j] = value;
            }
        }

        public static MatrixInt operator +(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);
            long[,] c = new long[n,n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    c[i, j] = a[i, j] + b[i, j];
                }
            }

            if (mod > 0)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        c[i, j] %= mod;
                    }
                }
            }

            return new MatrixInt(c, mod);
        }

        public static MatrixInt operator *(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);

            long[,] c = new long[n,n];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    for (int k = 0; k < n; k++)
                    {
                        c[i, j] += a[i, k] * b[k, j];
                        if (mod > 0)
                        {
                            c[i, j] %= mod;
                        }
                    }
                }
            }

            return new MatrixInt(c, mod);
        }
    }

    public static class Permutations
    {
        public static int[] GetRandomPermutation(int n)
        {
            int[] p = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = i;
            }

            Random random = new Random();
            for (int i = n - 1; i > 0; i--)
            {
                int j = random.Next(i + 1);
                int tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
            }

            return p;
        }

        public static T[] Shuffle<T>(this T[] array)
        {
            int length = array.Length;
            int[] p = GetRandomPermutation(length);
            T[] result = new T[length];
            for (int i = 0; i < length; i++)
            {
                result[i] = array[p[i]];
            }

            return result;
        }

        public static T[] ShuffleSort<T>(this T[] array)
        {
            var result = array.Shuffle();
            Array.Sort(result);
            return result;
        }
    }

    internal static class Algebra
    {
        public static long Phi(long n)
        {
            long result = n;
            for (long i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    while (n % i == 0)
                    {
                        n /= i;
                    }

                    result -= result / i;
                }
            }

            if (n > 1)
            {
                result -= result / n;
            }

            return result;
        }

        public static long BinPower(long a, long n, long mod)
        {
            long result = 1;

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result = (result * a) % mod;
                }

                a = (a * a) % mod;
                n >>= 1;
            }

            return result;
        }

        public static MatrixInt MatrixBinPower(MatrixInt a, long n)
        {
            MatrixInt result = MatrixInt.GetIdentityMatrix(a.Size, a.Mod);

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result *= a;
                }

                a *= a;
                n >>= 1;
            }

            return result;
        }

        public static long Gcd(long a, long b)
        {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static long ExtendedGcd(long a, long b, out long x, out long y)
        {
            if (b == 0)
            {
                x = 1;
                y = 0;
                return a;
            }

            long x1;
            long y1;
            long d = ExtendedGcd(b, a % b, out x1, out y1);
            x = y1;
            y = x1 - (a / b) * y1;
            return d;
        }

        public static long Lcm(long a, long b)
        {
            return (a / Gcd(a, b)) * b;
        }

        public static bool[] GetPrimes(int n)
        {
            n = Math.Max(n, 2);
            bool[] prime = new bool[n + 1];
            for (int i = 2; i <= n; i++)
            {
                prime[i] = true;
            }

            for (int i = 2; i * i <= n; i++)
            {
                if (prime[i])
                {
                    if ((long)i * i <= n)
                    {
                        for (int j = i * i; j <= n; j += i)
                        {
                            prime[j] = false;
                        }
                    }
                }
            }

            return prime;
        }

        public static long GetFibonacciNumber(long n, long mod = 0)
        {
            long[,] matrix = new long[,] { { 0, 1 }, { 1, 1 } };

            MatrixInt result = MatrixBinPower(new MatrixInt(matrix, mod), n);

            return result[1, 1];
        }

        public static long[] GetFibonacciSequence(int n)
        {
            long[] result = new long[n];
            result[0] = result[1] = 1;

            for (int i = 2; i < n; i++)
            {
                result[i] = result[i - 1] + result[i - 2];
            }

            return result;
        }

        public static long GetInverseElement(long a, long mod)
        {
            long x, y;
            long g = ExtendedGcd(a, mod, out x, out y);

            if (g != 1)
            {
                return -1;
            }

            return ((x % mod) + mod) % mod;
        }

        public static long[] GetAllInverseElements(long mod)
        {
            long[] result = new long[mod];
            result[1] = 1;
            for (int i = 2; i < mod; i++)
            {
                result[i] = (mod - (((mod / i) * result[mod % i]) % mod)) % mod;
            }

            return result;
        }

        public static int GetMinimalPrimeDivisor(int n)
        {
            for (int i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    return i;
                }
            }

            return n;
        }

        public static long Sqr(long x)
        {
            return x * x;
        }

        public static int SumOfDigits(long x, long baseMod = 10)
        {
            int res = 0;
            while (x > 0)
            {
                res += (int)(x % baseMod);
                x = x / baseMod;
            }
            return res;
        }
    }

    internal static class Reader
    {
        public static void ReadInt(out int a)
        {
            int[] number = new int[1];
            ReadInt(number);
            a = number[0];
        }

        public static void ReadInt(out int a, out int b)
        {
            int[] numbers = new int[2];
            ReadInt(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadInt(out int int1, out int int2, out int int3)
        {
            int[] numbers = new int[3];
            ReadInt(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static void ReadInt(out int int1, out int int2, out int int3, out int int4)
        {
            int[] numbers = new int[4];
            ReadInt(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
            int4 = numbers[3];
        }

        public static void ReadLong(out long a)
        {
            long[] number = new long[1];
            ReadLong(number);
            a = number[0];
        }

        public static void ReadLong(out long a, out long b)
        {
            long[] numbers = new long[2];
            ReadLong(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadLong(out long int1, out long int2, out long int3)
        {
            long[] numbers = new long[3];
            ReadLong(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static void ReadLong(out long int1, out long int2, out long int3, out long int4)
        {
            long[] numbers = new long[4];
            ReadLong(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
            int4 = numbers[3];
        }

        public static void ReadInt(int[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = int.Parse(list[i]);
            }
        }

        public static int[] ReadDigits()
        {
            // ReSharper disable AssignNullToNotNullAttribute
            return Console.ReadLine().Select(x => int.Parse(x.ToString())).ToArray();
            // ReSharper restore AssignNullToNotNullAttribute
        }

        public static void ReadLong(long[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = long.Parse(list[i]);
            }
        }

        public static void ReadDouble(double[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = double.Parse(list[i]);
            }
        }

        public static void ReadDouble(out double a, out double b)
        {
            double[] numbers = new double[2];
            ReadDouble(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadDouble(out double int1, out double int2, out double int3)
        {
            double[] numbers = new double[3];
            ReadDouble(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }
    }

    public interface IGraph
    {
        int Vertices { get; set; }

        IList<int> this[int i] { get; }

        void AddEdge(int u, int v);

        void AddOrientedEdge(int u, int v);
    }

    public class Graph : IGraph
    {
        private readonly List<int>[] m_Edges;

        public int Vertices { get; set; }

        public IList<int> this[int i]
        {
            get
            {
                return this.m_Edges[i];
            }
        }

        public Graph(int vertices)
        {
            this.Vertices = vertices;

            this.m_Edges = new List<int>[vertices];

            for (int i = 0; i < vertices; i++)
            {
                this.m_Edges[i] = new List<int>();
            }
        }

        public void AddEdge(int u, int v)
        {
            this.AddOrientedEdge(u, v);
            this.AddOrientedEdge(v, u);
        }

        public void AddOrientedEdge(int first, int second)
        {
            this.m_Edges[first].Add(second);
        }

        public int[] Bfs(int start)
        {
            int[] d = new int[Vertices];
            for (int i = 0; i < Vertices; i++)
            {
                d[i] = -1;
            }

            Queue<int> queue = new Queue<int>();
            queue.Enqueue(start);
            d[start] = 0;

            while (queue.Count > 0)
            {
                int v = queue.Dequeue();
                foreach (int t in this.m_Edges[v].Where(t => d[t] == -1))
                {
                    queue.Enqueue(t);
                    d[t] = d[v] + 1;
                }
            }

            return d;
        }
    }

    internal class SimpleSumTable
    {
        private readonly int[,] m_Sum;

        public SimpleSumTable(int n, int m, int[,] table)
        {
            m_Sum = new int[n + 1,m + 1];

            for (int i = 1; i < n + 1; i++)
            {
                for (int j = 1; j < m + 1; j++)
                {
                    m_Sum[i, j] = m_Sum[i, j - 1] + m_Sum[i - 1, j] - m_Sum[i - 1, j - 1] + table[i - 1, j - 1];
                }
            }
        }

        public int GetSum(int l, int b, int r, int t)
        {
            return m_Sum[r + 1, t + 1] - m_Sum[r + 1, b] - m_Sum[l, t + 1] + m_Sum[l, b];
        }
    }

    internal class SegmentTreeSimpleInt<T>
    {
        public int Size { get; private set; }

        private readonly T[] m_Tree;

        private readonly Func<T, T, T> m_Operation;

        private readonly T m_Null;

        public SegmentTreeSimpleInt(int size, Func<T, T, T> operation, T nullElement, IList<T> array = null)
        {
            this.Size = size;
            this.m_Operation = operation;
            this.m_Null = nullElement;

            m_Tree = new T[4 * size];
            if (array != null)
            {
                this.Build(array, 1, 0, size - 1);
            }
        }

        private void Build(IList<T> array, int v, int tl, int tr)
        {
            if (tl == tr)
            {
                m_Tree[v] = array[tl];
            }
            else
            {
                int tm = (tl + tr) / 2;
                this.Build(array, 2 * v, tl, tm);
                this.Build(array, 2 * v + 1, tm + 1, tr);
                this.CalculateNode(v);
            }
        }

        public T GetSum(int l, int r)
        {
            return GetSum(1, 0, Size - 1, l, r);
        }

        private T GetSum(int v, int tl, int tr, int l, int r)
        {
            if (l > r)
            {
                return m_Null;
            }

            if (l == tl && r == tr)
            {
                return m_Tree[v];
            }

            int tm = (tl + tr) / 2;

            return this.m_Operation(
                GetSum(2 * v, tl, tm, l, Math.Min(r, tm)), GetSum(2 * v + 1, tm + 1, tr, Math.Max(l, tm + 1), r));
        }

        public void Update(int pos, T newValue)
        {
            Update(1, 0, Size - 1, pos, newValue);
        }

        private void Update(int v, int tl, int tr, int pos, T newValue)
        {
            if (tl == tr)
            {
                m_Tree[v] = newValue;
            }
            else
            {
                int tm = (tl + tr) / 2;
                if (pos <= tm)
                {
                    Update(2 * v, tl, tm, pos, newValue);
                }
                else
                {
                    Update(2 * v + 1, tm + 1, tr, pos, newValue);
                }
                this.CalculateNode(v);
            }
        }

        private void CalculateNode(int v)
        {
            m_Tree[v] = this.m_Operation(m_Tree[2 * v], m_Tree[2 * v + 1]);
        }
    }

    internal struct Pair<TFirst, TSecond>
    {
        public Pair(TFirst first, TSecond second)
            : this()
        {
            this.First = first;
            this.Second = second;
        }

        public TFirst First { set; get; }

        public TSecond Second { set; get; }
    }

    internal class FenwickTreeInt64
    {
        public FenwickTreeInt64(int size)
        {
            this.m_Size = size;
            m_Tree = new long[size];
        }

        public FenwickTreeInt64(int size, IList<long> tree)
            : this(size)
        {
            for (int i = 0; i < size; i++)
            {
                Inc(i, tree[i]);
            }
        }

        public long Sum(int r)
        {
            long res = 0;
            for (; r >= 0; r = (r & (r + 1)) - 1)
            {
                res += m_Tree[r];
            }
            return res;
        }

        public long Sum(int l, int r)
        {
            return Sum(r) - Sum(l - 1);
        }

        public void Inc(int i, long x)
        {
            for (; i < m_Size; i = i | (i + 1))
            {
                m_Tree[i] += x;
            }
        }

        public void Set(int i, long x)
        {
            Inc(i, x - Sum(i, i));
        }

        private readonly int m_Size;

        private readonly long[] m_Tree;
    }

    internal class AccumulativeDictionary<TKey> : Dictionary<TKey, int>
    {
        public new void Add(TKey key, int value = 1)
        {
            if (this.ContainsKey(key))
            {
                base[key] += value;
            }
            else
            {
                base.Add(key, value);
            }
        }

        public new int this[TKey key]
        {
            get
            {
                return this.ContainsKey(key) ? base[key] : 0;
            }
            set
            {
                this.Add(key, value);
            }
        }
    }

    internal class PriorityQueue<T>
    {
        public PriorityQueue(Comparison<T> comparison = null)
        {
            if (comparison == null)
            {
                if (typeof(T).GetInterfaces().Any(i => i == typeof(IComparable<T>)))
                {
                    m_Comparison = (a, b) => ((IComparable<T>)a).CompareTo(b);
                }
                else
                {
                    throw new ApplicationException("Add comparer");
                }
            }
            else
            {
                m_Comparison = comparison;
            }
        }

        public int Count { get; private set; }

        public void Enqueue(T item)
        {
            m_List.Add(item);
            m_Indexes.Add(item, this.Count);
            this.Count++;
            Up(this.Count);
        }

        public T Peek()
        {
            return m_List[0];
        }

        public T Dequeue()
        {
            if (this.Count > 0)
            {
                var result = m_List[0];

                Swap(0, this.Count - 1);
                m_Indexes.Remove(m_List[this.Count - 1]);
                m_List.RemoveAt(this.Count - 1);
                this.Count--;
                this.Down(1);

                return result;
            }
            throw new ApplicationException("Couldn't get element from empty queue");
        }

        public void Update(T item)
        {
            int index = m_Indexes[item];
            this.Up(index + 1);
        }

        private readonly List<T> m_List = new List<T>();

        private readonly Dictionary<T, int> m_Indexes = new Dictionary<T, int>();

        private readonly Comparison<T> m_Comparison;

        private void Up(int index)
        {
            while (index > 1 && m_Comparison.Invoke(m_List[index - 1], m_List[index / 2 - 1]) > 0)
            {
                this.Swap(index - 1, index / 2 - 1);

                index = index / 2;
            }
        }

        private void Down(int index)
        {
            while (2 * index <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index - 1]) < 0
                   || 2 * index + 1 <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index]) < 0)
            {
                if (2 * index + 1 > this.Count || m_Comparison.Invoke(m_List[2 * index - 1], m_List[2 * index]) > 0)
                {
                    this.Swap(index - 1, 2 * index - 1);
                    index = 2 * index;
                }
                else
                {
                    this.Swap(index - 1, 2 * index);
                    index = 2 * index + 1;
                }
            }
        }

        private void Swap(int i, int j)
        {
            var tmp = m_List[i];
            m_List[i] = m_List[j];
            m_List[j] = tmp;

            m_Indexes[m_List[i]] = i;
            m_Indexes[m_List[j]] = j;
        }
    }

    internal class HamiltonianPathFinder
    {
        public static void Run()
        {
            int n, m;
            Reader.ReadInt(out n, out m);
            List<int>[] a = new List<int>[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = new List<int>();
            }
            for (int i = 0; i < m; i++)
            {
                int x, y;
                Reader.ReadInt(out x, out y);
                a[x].Add(y);
                a[y].Add(x);
            }

            var rnd = new Random();

            bool[] v = new bool[n];
            int[] p = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = -1;
            }
            int first = rnd.Next(n);
            int cur = first;
            v[cur] = true;

            int count = 1;

            while (true)
            {
                var unb = a[cur].Where(u => !v[u]).ToList();
                int d = unb.Count;
                if (d > 0)
                {
                    int next = unb[rnd.Next(d)];
                    v[next] = true;
                    p[cur] = next;
                    cur = next;
                    count++;
                }
                else
                {
                    if (count  == n && a[cur].Contains(first))
                    {
                        p[cur] = first;
                        break;
                    }

                    d = a[cur].Count;
                    int pivot;
                    do
                    {
                        pivot = a[cur][rnd.Next(d)];
                    }
                    while (p[pivot] == cur);

                    int next = p[pivot];

                    int x = next;
                    int y = -1;
                    while (true)
                    {
                        int tmp = p[x];
                        p[x] = y;
                        y = x;
                        x = tmp;
                        if (y == cur)
                        {
                            break;
                        }
                    }
                    p[pivot] = cur;
                    cur = next;
                }
            }

            cur = first;
            do
            {
                Console.Write("{0} ", cur);
                cur = p[cur];
            }
            while (cur != first);
        }

        public static void WriteTest(int n)
        {
            Console.WriteLine("{0} {1}", 2 * n, 2 * (n - 1) + n);
            for (int i = 0; i < n - 1; i++)
            {
                Console.WriteLine("{0} {1}", 2 * i, 2 * i + 2);
                Console.WriteLine("{0} {1}", 2 * i + 1, 2 * i + 3);
                //Console.WriteLine("{0} {1}", 2 * i + 1, 2 * i + 2);
                //Console.WriteLine("{0} {1}", 2 * i, 2 * i + 3);
            }
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine("{0} {1}", 2 * i, 2 * i + 1);
            }
        }
    }

    internal class Program
    {
        private static StreamReader m_InputStream;

        private static StreamWriter m_OutStream;

        private static void OpenFiles()
        {
            m_InputStream = new StreamReader("input.txt"); //File.OpenText("input.txt");
            Console.SetIn(m_InputStream);

            m_OutStream = new StreamWriter("output.txt"); //File.CreateText("output.txt");
            Console.SetOut(m_OutStream);
        }

        private static void CloseFiles()
        {
            m_OutStream.Flush();

            m_InputStream.Dispose();
            m_OutStream.Dispose();
        }

        private static void Main()
        {
           // OpenFiles();

            new Solution().Solve();

           // CloseFiles();
        }
    }

    internal class Solution
    {
        public void Solve()
        {
            int n = 3;
            int[][] a = new int[3][];
            for (int i = 0; i < 3; i++)
            {
                a[i] = new int[3];
            }
            for (int i = 0; i < 3; i++)
            {
                Reader.ReadInt(a[i]);
            }

            for (int x = 1; x < 100001; x++)
            {
                a[0][0] = x;
                int s = a[0].Sum();
                a[1][1] = s - a[1][0] - a[1][2];
                a[2][2] = s - a[2][0] - a[2][1];

                bool ok = true;

                for (int i = 0; i < 3; i++)
                {
                    if (s != a[0][i] + a[1][i] + a[2][i])
                    {
                        ok = false;
                    }
                }

                if (s != a[0][0] + a[1][1] + a[2][2])
                {
                    ok = false;
                }

                if (s != a[0][2] + a[1][1] + a[2][0])
                {
                    ok = false;
                }

                if (ok)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            Console.Write("{0} ", a[i][j]);
                        }
                        Console.WriteLine();
                    }
                    return;
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;

// ~

namespace CF {
    class Program {

        static void Main(string[] args) {

#if DEBUG
            TextReader reader = new StreamReader("../../input.txt");
            TextWriter writer = Console.Out;
#else
			TextReader reader = Console.In;
            TextWriter writer = Console.Out;
#endif

            var vals1 = reader.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var s1 = vals1.Sum();
            var vals2 = reader.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var s2 = vals2.Sum();
            var vals3 = reader.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var s3 = vals3.Sum();

            int x = 0;
            int y = 0;
            int z = 0;

            for (int i = 0; i <= 3 * 100000; i++) {

                x = i - s1;
                y = i - s2;
                z = i - s3;

                if (x > 0 && y > 0 && z > 0
                    && x + y + z == i
                    && vals3[0] + y + vals1[2] == i
                    && x + vals2[0] + vals3[0] == i
                    && y + vals1[1] + vals3[1] == i
                    && z + vals1[2] + vals2[2] == i
                    ) {
                    break;
                }

            }

            Console.WriteLine(x + " " + vals1[1] + " " + vals1[2]);
            Console.WriteLine(vals2[0] + " " + y + " " + vals2[2]);
            Console.WriteLine(vals3[0] + " " + vals3[1] + " " + z);

            //writer.Close();
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] arr = new int[3, 3];
            for (int i = 0; i < 3; i++)
            {
                String line = Console.ReadLine();
                String[] ps = line.Split(' ');
                for (int j = 0; j < 3; j++)
                {
                    arr[i, j] = int.Parse(ps[j]);
                }
            }

            arr[0, 0] = ((arr[1, 0] + arr[1, 2]) - (arr[0, 1] + arr[0, 2]) + (arr[2, 0] + arr[2, 1])) / 2;
            arr[1, 1] = (arr[2, 0] + arr[2, 1]) - arr[0, 0];
            arr[2, 2] = (arr[0, 0] + arr[0, 1]) - arr[1, 2];
            for (int i = 0; i < 3; i++)
            {

                for (int j = 0; j < 3; j++)
                {
                    Console.Write(arr[i, j] + " ");
                }
                Console.WriteLine();
            }
        }
    }
}

using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

//BF4

namespace CSharp_Contests
{
    public class Program
    {
        public static void Main( ) {
            int[] L1 = Console.ReadLine().Split(new char[ 1 ] { ' ' }).Select(a => int.Parse(a)).ToArray();
            int[] L2 = Console.ReadLine().Split(new char[ 1 ] { ' ' }).Select(a => int.Parse(a)).ToArray();
            int[] L3 = Console.ReadLine().Split(new char[ 1 ] { ' ' }).Select(a => int.Parse(a)).ToArray();
            long L1S = L1.Sum(), L2S = L2.Sum(), L3S = L3.Sum();
            long LS = ( L1S + L2S + L3S ) / 2;
            Console.WriteLine("{0} {1} {2}\n{3} {4} {5}\n{6} {7} {8}", LS - L1S, L1[ 1 ], L1[ 2 ], L2[ 0 ], LS - L2S, L2[ 2 ], L3[ 0 ], L3[ 1 ], LS - L3S);
#if DEBUG
            Console.ReadLine();
#endif
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Diagnostics;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split(' ');
            string[] s2 = Console.ReadLine().Split(' ');
            string[] s3 = Console.ReadLine().Split(' ');

            int a = int.Parse(s1[0]);
            int b = int.Parse(s1[1]);
            int c = int.Parse(s1[2]);
            int d = int.Parse(s2[0]);
            int e = int.Parse(s2[1]);
            int f = int.Parse(s2[2]);
            int h = int.Parse(s3[0]);
            int i = int.Parse(s3[1]);
            int j = int.Parse(s3[2]);

            for (int q = 1; q < 100001; q++ )
            {
                e = q;
                int summ = b + e + i;
                a = summ - b - c;
                j = summ - f - c;

                if(a+e+j == summ)
                {
                    Console.WriteLine(a+" "+b+" "+c);
                    Console.WriteLine(d + " " + e + " " + f);
                    Console.WriteLine(h + " " + i + " " + j);
                    return;
                }
            }
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;

namespace CodeForces
{
    class Prob259B
    {
        //Little Elephant loves magic squares very much.

        //A magic square is a 3 × 3 table, each cell contains some positive integer. At that the sums of integers in
        //all rows, columns and diagonals of the table are equal.

        //The Little Elephant remembered one magic square. He started writing this square on a piece of paper, but as
        //he wrote, he forgot all three elements of the main diagonal of the magic square. Fortunately, the Little
        //Elephant clearly remembered that all elements of the magic square did not exceed 10^5.

        //Help the Little Elephant, restore the original magic square, given the Elephant's notes.

        int[][] square;

        public Prob259B(String[] s)
        {
            square = new int[s.Length][];
            String[] temp;
            for (int i = 0; i < s.Length; ++i)
            {
                temp = s[i].Split(' ');
                square[i] = new int[temp.Length];
                for (int j = 0; j < temp.Length; ++j)
                {
                    square[i][j] = Convert.ToInt32(temp[j]);
                }
            }
        }

        public String solve()
        {
            int[] rowSums = new int[square.Length];
            for (int i = 0; i < square.Length; ++i)
            {
                rowSums[i] = 0;
                for (int j = 0; j < square[i].Length; ++j)
                {
                    rowSums[i] += square[i][j];
                }
            }
            int trueSum = rowSums[0];
            int upperLeft = 0;
            for (int i = 1; i < rowSums.Length; ++i)
            {
                upperLeft += rowSums[i];
            }
            upperLeft -= trueSum;
            upperLeft /= 2;
            trueSum += upperLeft;

            StringBuilder result = new StringBuilder();
            for (int i = 0; i < square.Length; ++i)
            {
                for (int j = 0; j < square[i].Length; ++j)
                {
                    if (square[i][j] == 0)
                    {
                        result.Append(trueSum - rowSums[i]);
                    }
                    else
                    {
                        result.Append(square[i][j]);
                    }
                    if (j < square[i].Length - 1)
                    {
                        result.Append(" ");
                    }
                }
                if (i < square.Length - 1)
                {
                    result.Append("\n");
                }
            }
            return result.ToString();
        }

        public override String ToString()
        {
            StringBuilder result = new StringBuilder();
            for (int i = 0; i < square.Length; ++i)
            {
                result.Append("(" + String.Join(",", square[i]) + ") ");
            }
            return result.ToString();
        }

        static void Main(string[] arg)
        {
            int numDims = 3;
            String[] input = new String[numDims];
            for (int i = 0; i < numDims; ++i)
            {
                input[i] = Console.ReadLine();
            }
            Prob259B prob = new Prob259B(input);
            Console.WriteLine(prob.solve());
        }
    }
}

using System;
using System.IO;
using System.Linq;
using System.Text;

namespace Little_Elephant_and_Magic_Square
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            const int n = 3;
            var nn = new int[n][];
            for (int i = 0; i < n; i++)
            {
                nn[i] = new int[n];
                for (int j = 0; j < n; j++)
                {
                    nn[i][j] = Next();
                }
            }

            int a = nn[0].Sum();
            int b = nn[1].Sum();
            int c = nn[2].Sum();

            int x = (b + c - a)/2;
            nn[0][0] = x;
            nn[1][1] = x + a - b;
            nn[2][2] = x + a - c;

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    writer.Write(nn[i][j]);
                    writer.Write(' ');
                }
                writer.WriteLine();
            }

            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
using System.Numerics;
using System.Globalization;
using System.Threading;

namespace probleme {
    class Program {
        static void Main(string[] args) {
            //Console.SetIn(new StreamReader("file.txt"));
            int[][] m = new int[3][];
            int[] c = new int[3];
            for (int i = 0; i < 3; i++) {
                m[i] = Array.ConvertAll(Console.ReadLine().Split(' '), tz => int.Parse(tz));
                c[i] = m[i].Sum();
            }
            int s = c.Sum() / 2;
            for (int i = 0; i < 3; i++) {
                m[i][i] = s - c[i];
                for (int j = 0; j < 3; j++) {
                    Console.Write("{0} ", m[i][j]);
                }
                Console.WriteLine();
            }
            //Console.ReadKey();
        }
    }
}

using System;
using System.Linq;
using System.Collections.Generic;

public class App1
{
    public static void Main()
    {
        Func<string> read = ()=>Console.ReadLine();
        Action<object> write = _=>Console.WriteLine(_.ToString());

        var m=util.RangeN(1,3).Map(_=>read().ToIntA()).ToArray();
        var i=0;
        while(true)
        {
            var a0=i;
            var s=a0+m[0][1]+m[0][2];
            var a1=s-m[1][0]-m[1][2];
            var a2=s-a0-a1;
            if( (m[2][0]+a1+m[0][2])==s &&
                (m[0][2]+m[1][2]+a2)==s)
            {
                m[0][0]=a0;
                m[1][1]=a1;
                m[2][2]=a2;
                break;
            }
            i++;
        }
        m.Map(v=>string.Format("{0} {1} {2}",v[0],v[1],v[2]))
            .Foreach(st=>write(st));
    }

}

static class Exts
{
    public static int ToInt(this string s)
    {
        return int.Parse(s);
    }

    public static int[] ToIntA(this IEnumerable<string> args)
    {
        return args.Map(ToInt).ToArray();
    }

    public static int[] ToIntA(this string s)
    {
        return ToIntA(SplitBySpace(s));
    }

    public static string[] SplitBySpace(this string s)
    {
        return s.Split(new[]{" "},StringSplitOptions.RemoveEmptyEntries);
    }

    public static void Foreach<T>(this IEnumerable<T> l,Action<T> f)
    {
        foreach(var i in l) f(i);
    }
}

static class FuncExts
{
    public static IEnumerable<U> Map<T,U>(this IEnumerable<T> l,Func<T,U> f)
    {
        return l.Select(f);
    }

    public static IEnumerable<T> Flt<T,U>(this IEnumerable<T> l,Func<T,bool> f)
    {
        return l.Where(f);
    }

    public static T Nth<T>(this IEnumerable<T> l,int n)
    {
        var list = l as IList<T>;
        return (list!=null)?list[n-1]:l.Skip(n-1).First();
    }

    public static T Rd<T>(this IEnumerable<T> l,T df,Func<T,T,T> f)
    {
        return Fold(l,df,f);
    }

    public static U Fold<T,U>(this IEnumerable<T> l,U df,Func<U,T,U> f)
    {
        foreach(var i in l)
        {
            df=f(df,i);
        }
        return df;
    }

    public static IEnumerable<U> Scan<T,U>(this IEnumerable<T> l,Func<U,T,U> f,U df)
    {
        foreach(var i in l)
        {
            df=f(df,i);
            yield return df;
        }
    }
}

static class util
{
    public static IEnumerable<int> RangeN(int from,int to)
    {
        while(from<=to)
        {
            yield return from;
            from++;
        }
    }
}

using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace LittleElephantandMagicSquare
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			var r1 = Console.ReadLine().Split(' ').ToList().Select(int.Parse).ToList();
			var r2 = Console.ReadLine().Split(' ').ToList().Select(int.Parse).ToList();
			var r3 = Console.ReadLine().Split(' ').ToList().Select(int.Parse).ToList();

			int sr1 = r1.Sum (); int sr2 = r2.Sum (); int sr3 = r3.Sum ();

			int x = (sr3 + (sr2 - sr1)) / 2; int y = sr3 - x; int z = sr1 + x - sr3;

			r1 [0] = x; r2 [1] = y; r3 [2] = z;

			string tmp = "";
			r1.ForEach (c => tmp += c + " ");
			Console.WriteLine (tmp);
			tmp = "";
			r2.ForEach (c => tmp += c + " ");
			Console.WriteLine (tmp);
			tmp = "";
			r3.ForEach (c => tmp += c + " ");
			Console.WriteLine (tmp);
		}
	}
}

using System;
using System.Collections.Generic;
using System.IO;

namespace prB {

    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter("output");
        private static readonly StreamReader reader = new StreamReader("input");
#endif
        static void Main(string[] args) {
            int a = Next();
            int b = Next();
            int c = Next();
            int d = Next();
            int e = Next();
            int f = Next();
            int g = Next();
            int h = Next();
            int k = Next();
            int dd = d + g - c - f;
            for(a = 0; a <= 100000; a++) {
                k = a + dd;
                if(k > 100000)
                    continue;
                if(k < 0)
                    continue;
                e = a + b + c - d - f;
                if(e > 100000)
                    continue;
                if(e < 0)
                    continue;
                long s = a + b + c;
                bool ans = true;
                ans &= d + e + f == s;
                ans &= g + h + k == s;
                ans &= a + d + g == s;
                ans &= b + e + h == s;
                ans &= c + f + k == s;
                ans &= a + e + k == s;
                if(ans)
                    break;
            }
            writer.WriteLine("{0} {1} {2}", a, b, c);
            writer.WriteLine("{0} {1} {2}", d, e, f);
            writer.WriteLine("{0} {1} {2}", g, h, k);
            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static int Next() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
public class Codeforces
{
    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
        reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
        var ar = new int[9];
        for (int i = 0; i < 9; i++)
        {
            ar[i] = Next();
        }
        var sum = ar.Sum() / 2;
        ar[0] = sum - ar[1] - ar[2];
        ar[4] = sum - ar[3] - ar[5];
        ar[8] = sum - ar[6] - ar[7];
        WriteArray(ar.Take(3));
        WriteArray(ar.Skip(3).Take(3));
        WriteArray(ar.Skip(6));
        reader.Close();
        writer.Close();
    }
    #region Read / Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }
    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }
    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write<T>(params T[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }
    private static int Next()
    {
        int c;
        int res = 0;
        do
        {
            c = reader.Read();
            if (c == -1)
                return res;
        } while (c != '-' && (c < '0' || c > '9'));
        int sign = 1;
        if (c == '-')
        {
            sign = -1;
            c = reader.Read();
        }
        res = c - '0';
        while (true)
        {
            c = reader.Read();
            if (c < '0' || c > '9')
                return res * sign;
            res *= 10;
            res += c - '0';
        }
    }
    #endregion
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace codeforces
{
	class Program
	{
		public const int Osn = 1000000007;

		public class User
		{
			public int c;

			public int r;
		}

		public class Point
		{
			public int x;

			public int y;
		}

		public class StringInt
		{
			public string x;

			public int y;
		}

		public class StringString
		{
			public string x;

			public string y;
		}

		public class IntInt
		{
			public int x;

			public int y;
		}

		public class SIComparer : IComparer<StringInt>
		{
			public int Compare(StringInt x, StringInt y)
			{
				return x.x.CompareTo(y.x);
			}
		}

		public class XComparer : IComparer<int>
		{
			public int Compare(int x, int y)
			{
				if (x % 10 > y % 10)
					return -1;
				return 1;
			}
		}

		public class Comparer : IComparer<User>
		{
			public int Compare(User x, User y)
			{
				if (x.c < y.c || (x.c == y.c && x.r < y.r))
					return -1;
				return 1;
			}
		}

		public static long getGcd(long a, long b)
		{
			if (b == 0)
				return a;
			return getGcd(b, a % b);
		}

		public static void WriteYESNO(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string getString()
		{
			return Console.ReadLine();
		}

		public static List<int> getList()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static List<long> getLongList()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(long.Parse).ToList();
		}

		public static int Min(int x, int y)
		{
			return Math.Min(x, y);
		}

		public static int Max(int x, int y)
		{
			return Math.Max(x, y);
		}

		public static int Abs(int x)
		{
			return Math.Abs(x);
		}

		public static int getInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static long getLong()
		{
			var s = Console.ReadLine();
			return long.Parse(s);
		}

		public class Edge
		{
			public int v;

			public int w;
		}

		public class Vertex
		{
			public List<Edge> edges;

			public int ct;

			public bool was;
		}

		public static bool isPrime(int x)
		{
			for (var i = 2; i * i <= x; ++i)
				if (x % i == 0)
					return false;
			return true;
		}

		private static void Main(string[] args)
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/
			var l = new List<List<int>> { getList(), getList(), getList() };
			var a1 = l[0][1];
			var a2 = l[0][2];
			var a3 = l[1][0];
			var a4 = l[1][2];
			var a5 = l[2][0];
			var a6 = l[2][1];
			var z = (a1 + 2 * a2 - a6) / 2;
			var x = a2 + a5 - z;
			var y = x + a1 + a2 - a3 - a4;
			Console.WriteLine("{0} {1} {2}", x, a1, a2);
			Console.WriteLine("{0} {1} {2}", a3, y, a4);
			Console.WriteLine("{0} {1} {2}", a5, a6, z);
			Console.ReadLine();
		}
	}
}

using System;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[][] matrix = new int[3][];
            int[] s = new int[3];

            for (int i = 0; i < 3; i++)
            {
                matrix[i] = new int[3];
                s[i] = 0;

                string[] lineParts = Console.ReadLine().Split(' ');

                for (int j = 0; j < 3; j++)
                {
                    matrix[i][j] = int.Parse(lineParts[j]);
                    s[i] += matrix[i][j];
                }
            }

            int max = Math.Max(s[0], Math.Max(s[1], s[2]));

            matrix[0][0] = max - matrix[0][1] - matrix[0][2] + 1;
            matrix[1][1] = max - matrix[1][0] - matrix[1][2] + 1;
            matrix[2][2] = max - matrix[2][0] - matrix[2][1] + 1;

            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(matrix[i][0] + " " + matrix[i][1] + " " + matrix[i][2]);
            }
        }
    }
}

using System;
using System.Text;

namespace codeforces_round_157_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] arr = new int[3,3];
            int sum = 0;
            int sum2 = 0;
            for (int i = 0; i < 3; i++)
            {
                string[] st = Console.ReadLine().Split(' ');
                for (int j = 0; j < 3; j++)
                {
                    arr[i, j] = Int32.Parse(st[j]);
                    sum += arr[i, j];
                }
            }
            arr[0,0] = sum - (arr[0, 1] + arr[0, 2]);
            arr[2, 2] = sum - (arr[0, 2] + arr[1, 2]);
            arr[1, 1] = (arr[0, 0] + arr[2, 2])/2;
            int x = 0;
            foreach (int i in arr)
            {
                if (x++ < 2)
                    Console.Write(i+" ");
                else
                {
                    Console.WriteLine(i);
                    x = 0;
                }
            }
        }
    }
}

using System;
using System.Text;

namespace codeforces_round_157_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] arr = new int[3,3];
            int sum = 0;
            int sum2 = 0;
            for (int i = 0; i < 3; i++)
            {
                string[] st = Console.ReadLine().Split(' ');
                for (int j = 0; j < 3; j++)
                {
                    arr[i, j] = Int32.Parse(st[j]);
                    sum += arr[i, j];
                }
            }
            Console.WriteLine(sum /= 2);
            arr[0,0] = sum - (arr[0, 1] + arr[0, 2]);
            arr[2, 2] = sum - (arr[0, 2] + arr[1, 2]);
            arr[1, 1] = (arr[0, 0] + arr[2, 2])/2;
            int x = 0;
            foreach (int i in arr)
            {
                if (x++ < 2)
                    Console.Write(i+" ");
                else
                {
                    Console.WriteLine(i);
                    x = 0;
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication12_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string z1 = "", z2 = "", z3="";
            string k1 = "", k2 = "", k3 = "";
            z1 = Console.ReadLine();
            z1 = z1.Replace(" ","");
            z2 = Console.ReadLine();
            z2 = z2.Replace(" ", "");
            z3 = Console.ReadLine();
            z3 = z3.Replace(" ", "");
            k1 = Convert.ToString(Convert.ToInt32(
                (z2.Substring(2,1))+Convert.ToInt32(z3.Substring(1,1)))/2
                );
            z1.Replace("0", k1);

            k2 = Convert.ToString(Convert.ToInt32(
                (z1.Substring(2, 1)) + Convert.ToInt32(z3.Substring(0, 1))) / 2
                );
            z2.Replace("0", k2);

            k3= Convert.ToString(Convert.ToInt32(
                    (z2.Substring(0, 1)) + Convert.ToInt32(z1.Substring(1, 1))) / 2
                      );

            z3.Replace("0", k3);

            Console.WriteLine(z1.Substring(0, 1) + " " + z1.Substring(1, 1) + " " + z1.Substring(2, 1));
            Console.WriteLine(z2.Substring(0, 1) + " " + z2.Substring(1, 1) + " " + z2.Substring(2, 1));
            Console.WriteLine(z3.Substring(0, 1) + " " + z3.Substring(1, 1) + " " + z3.Substring(2, 1));

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication12_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string z1 = "", z2 = "", z3="";
            string k1 = "", k2 = "", k3 = "";
            int y12 = 0, y13 = 0;
            int y21 = 0, y23 = 0;
            int y31 = 0, y32 = 0;

            z1 = Console.ReadLine();
            z1 = z1.Replace(" ","");
            z2 = Console.ReadLine();
            z2 = z2.Replace(" ", "");
            z3 = Console.ReadLine();
            z3 = z3.Replace(" ", "");

            y12=Convert.ToInt32((z1.Substring(1,1)));
            y13=Convert.ToInt32((z1.Substring(2,1)));

            y21=Convert.ToInt32((z2.Substring(0,1)));
            y23=Convert.ToInt32((z2.Substring(2,1)));

            y31=Convert.ToInt32((z3.Substring(0,1)));
            y32=Convert.ToInt32((z3.Substring(1,1)));

            k1 = Convert.ToString((y23+y32)/2);
            z1= z1.Replace("0", k1);

            k2 = Convert.ToString(Convert.ToInt32((y13+y31)/2));
            z2=z2.Replace("0", k2);

            k3= Convert.ToString(Convert.ToInt32((y21+y12)/2));
            z3=z3.Replace("0", k3);

            Console.WriteLine(z1.Substring(0, 1) + " " + z1.Substring(1, 1) + " " + z1.Substring(2, 1));
            Console.WriteLine(z2.Substring(0, 1) + " " + z2.Substring(1, 1) + " " + z2.Substring(2, 1));
            Console.WriteLine(z3.Substring(0, 1) + " " + z3.Substring(1, 1) + " " + z3.Substring(2, 1));

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication12_a
{
    class Program
    {
        static void Main(string[] args)
        {

            int[,] a = new int[3, 3];
            string[] data=new string[3];
            for (int i = 0; i < 3; i++)
            {
                data = Console.ReadLine().Split(' ');
                a[0, i] = int.Parse(data[0]);
                a[1, i] = int.Parse(data[1]);
                a[2, i] = int.Parse(data[2]);
            }

            a[0, 0] = (a[1, 2] + a[2, 1]) / 2;
            a[1, 1] = (a[0, 2] + a[2, 0]) / 2;
            a[2, 2] = (a[1, 0] + a[0, 1]) / 2;

            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(a[i, 0] + " " + a[i, 1] + " " + a[i, 2]);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeForces
{
    class Program_R157_Div2_B
    {
        static void Main(string[] args)
        {
            int[] a = new int[10];
            int sum;
            for (int i = 0; i < 3; i++)
            {
                string[] s = (Console.ReadLine().Split());
                a[i * 3 + 1] = Convert.ToInt32(s[0]);
                a[i * 3 + 2] = Convert.ToInt32(s[1]);
                a[i * 3 + 3] = Convert.ToInt32(s[2]);
            }

            for (int i = 1; i < 100000; i++)
            {
                a[5] = i;
                sum = a[4] + a[5] + a[6];
                if (sum == a[2] + a[5] + a[8]
                    && sum == a[3] + a[5] + a[7])
                {
                    a[1] = sum - a[2] - a[3];
                    a[9] = sum - a[7] - a[8];
                    if (sum == a[1] + a[4] + a[7]
                        && sum == a[3] + a[6] + a[9]
                        && sum == a[1] + a[5] + a[9])
                        break;
                }
            }

            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine("{0} {1} {2}", a[i * 3 + 1], a[i * 3 + 2], a[i * 3 + 3]);
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Coderandom
{
    class Program
    {
        static void Print(int[,] m,int[]a)
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (i==j)
                    {
                        Console.Write(a[i]+" ");
                    }
                    else
                    {
                        Console.Write(m[i,j]+" ");
                    }
                }
                Console.WriteLine();
            }
        }
        static void Main(string[] args)
        {
            int[,] matrix = new int[3, 3];
            int [] mas = new int[3];
            int[]ind = new int[3];
            for (int i = 0; i < 3; i++)
            {
                string[] ss = Console.ReadLine().Split(' ');

                for (int j = 0; j < 3; j++)
                {
                    matrix[i, j] = int.Parse(ss[j]);
                    mas[i] += matrix[i, j];
                }
            }

            for (int i = 0; i < 100000; i++)
            {
                ind[0] = i ;
                ind[1] = mas[0]+i - mas[1];
                ind[2] = mas[0] + i - mas[2];

                if(ind[0]+ind[2]+ind[1]==i+mas[0]) break;
            }

            Print(matrix,ind);

        }
    }
}

using System;
using System.IO;
using System.Linq;
using System.Text;

namespace Little_Elephant_and_Magic_Square
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            const int n = 3;
            var nn = new int[n][];
            for (int i = 0; i < n; i++)
            {
                nn[i] = new int[n];
                for (int j = 0; j < n; j++)
                {
                    nn[i][j] = Next();
                }
            }

            int a = nn[0].Sum();
            int b = nn[1].Sum();
            int c = nn[2].Sum();

            int x = (b + c - a)/2;
            nn[0][0] = x;
            nn[1][1] = x + a - b;
            nn[2][2] = x + a - c;

            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}