#include <iostream>
#include <vector>

using namespace std;

int main()
{   //za n=2 za 15 poena
    vector <int> vek;
    int n,m;
    cin>>n>>m;
    int matrica[m+1][n+1];
    for(int i=1; i<=m; i++){
        for(int j=1; j<=n; j++){
            cin>>matrica[i][j];
        }
    }

    cout<<"++++++++"<<endl;

    for(int i=1; i<=m; i++){
        for(int j=1; j<=n; j++){
            cout<<matrica[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<"++++++++"<<endl;




    for(int i=1; i<=m; i++){
        int a = 1;
        int zbir=0;
        for(int j=1; j<=m; j++){
            zbir = zbir +  matrica[j][a];
            if(j == i){
                a=a+1;
            zbir = zbir +  matrica[j][a];
            }
            cout<<matrica[j][a]<<endl;
        }
        vek.push_back(zbir);
    }
    int minimum;
    minimum = 2147483646;
    for(int i=0; i<vek.size(); i++){
            cout<<vek.at(i)<<"-";
        if(vek.at(i)<minimum){
            minimum = vek.at(i);
        }
    }
    cout<<minimum;


//aaaaaaaaa
    return 0;
}