#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int red[n], kolona[n];
    int kolikoured = 0;
    int kolikoukol = 0;
    for(int i=0;i<n;i++){
        cin >> red[i] >> kolona[i];
    }

    //------------------------------------------

    for(int i=0;i<n;i++){
        if(red[i]!=kolona[i]) cout << "-1\n";
        else{
            for(int r=0;r<n;r++){
                for(int k=0;k<n;k++){
                    if(kolikoukol%i!=0){
                        cout << "1 ";
                    }
                    else cout << "0 ";
                }
                cout << endl;

            }
        }
    }

    return 0;
}