#include<iostream>
using namespace std;

//write your code here
class Matrix{
  private:
    int arr[3][3];
  public:
    friend istream& operator >> (istream& in,Matrix &matrix);
    friend ostream& operator << (ostream& out,const Matrix& matrix);
    friend Matrix operator + (Matrix &a,Matrix &b);
    void setArr(int i,int j,int data){
        arr[i][j] = data;
    }
    int getArr(int i,int j) const{
    //                      ^^^^^ // Added const
        return arr[i][j];
    }
    Matrix& operator = (const Matrix &b);
    //                  ^^^^^ // Added const
};
istream& operator >> (istream& in,Matrix &matrix)
{
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            in >> matrix.arr[i][j];
    return in;
}
ostream& operator << (ostream& out,const Matrix &matrix){
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
            out << matrix.arr[i][j] << " ";
        out << endl;
    }       
    return out;
}
Matrix operator + (Matrix &a,Matrix &b){
    Matrix temp;
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            temp.setArr(i,j,(a.getArr(i,j)+b.getArr(i,j)));
    return temp;

}
Matrix& Matrix::operator = (const Matrix &b){
//                          ^^^^^ // Added const
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            arr[i][j] = b.getArr(i,j);
    return *this;
}
int main()
{
    Matrix a1,a2,a3,a4;
    cin >> a1;
    cin >> a2;
    a4 = a2;
    a3 = (a1+a4); // No errors now
    cout << a1 << endl;
    cout << a2 << endl;
    cout << a3 << endl;
    return 0;
}