#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

/**
 * Returns the least index of elements that are modified, wrapped with Some.
 * If the entire array is reversed, it returns None instead.
 * v's elements must be pairwise distinct.
 */
fn next_permutation<T: Ord>(v: &mut [T]) -> Option<usize> {
    let mut tail_dec: usize = 1;
    let n = v.len();
    while tail_dec < n {
        if v[n - tail_dec - 1] > v[n - tail_dec] {
            tail_dec += 1;
        } else {
            break;
        }
    }
    // v[n - tail_dec .. n] is strictly decreasing
    if tail_dec < n {
        let x = n - tail_dec - 1;
        let mut y = n;
        {
            let pivot = &v[x];
            for i in (n - tail_dec .. n).rev() {
                if v[i] > *pivot {
                    y = i;
                    break;
                }
            }
            assert!(y < n);
        }
        v.swap(x, y);
    }
    v[n - tail_dec .. n].reverse();
    if tail_dec < n {
        Some(n - tail_dec - 1)
    } else {
        None
    }
}

fn check(n: usize, dist: &[Vec<u64>]) -> Result<(), (usize, Vec<usize>, HashSet<u64>)> {
    let mut seen = HashSet::new();
    let mut p: Vec<_> = (0..n).collect();
    let mut col = 0;
    let mut ret = Ok(());
    loop {
        if p[0] < p[n - 1] {
            let mut tot = 0;
            for i in 0..n - 1 {
                tot += dist[p[i]][p[i + 1]];
            }
            if seen.contains(&tot) {
                ret = Err(p.clone());
                col += 1;
            }
            seen.insert(tot);
        }
        if let None = next_permutation(&mut p) { break; }
    }
    ret.map_err(|x| (col, x, seen))
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(n: usize);
    if n == 2 {
        puts!("0 1\n1 0\n");
        return;
    }
    let ans10 = r#"
0 43733096 2046691295 18934377720 4658971973 641799750 6011777697 15246780994 8266535805 15942572220
43733096 0 4843284376 6275044395 6243669688 15082385657 19966146264 14318353847 15668855680 2272839581
2046691295 4843284376 0 979837798 15224040334 17442829658 4618804939 1887361812 10849431067 6426434783
18934377720 6275044395 979837798 0 18075206162 15227517005 3445550250 16470366181 9375943486 14473952917
4658971973 6243669688 15224040334 18075206162 0 19438012670 1476343885 19332884528 18404956395 17188634002
641799750 15082385657 17442829658 15227517005 19438012670 0 16425514789 15286003109 2265091074 3999525963
6011777697 19966146264 4618804939 3445550250 1476343885 16425514789 0 14548974588 1419858351 16676894942
15246780994 14318353847 1887361812 16470366181 19332884528 15286003109 14548974588 0 1950721996 10071259397
8266535805 15668855680 10849431067 9375943486 18404956395 2265091074 1419858351 1950721996 0 13089405140
15942572220 2272839581 6426434783 14473952917 17188634002 3999525963 16676894942 10071259397 13089405140 0
"#;
    if n == 10 {
        puts!("{}", ans10);
        return;
    }
    let mut dist = vec![vec![0; n]; n];
    let seq = [1, 2, 4, 7, 12, 20, 33, 54, 88, 143];
    // random
    const MOD: u64 = 1_000_000_007 * 1_003;
    let hm: HashMap<i32, i32> = HashMap::new();
    use std::hash::{Hasher, BuildHasher};
    let mut hash = hm.hasher().build_hasher();
    hash.write_u32(8128);
    let mut x: u64 = hash.finish() % MOD;
    let a = 13333;
    let b = 4247;
    const W: u64 = 20_000_000_000;
    const V: u64 = 1_000;
    let mut nxt = || {
        x = (a * x + b) % MOD;
        x
    };
    for i in 0..n {
        for j in 0..i {
            let mut t = seq[j];
            for _ in 0..i { t *= 20; t %= W }
            dist[i][j] = ((nxt() % W) & !1) + 1;
            if (i + j) % 2 == 1 {
                dist[i][j] += 1;
            }
            //dist[i][j] = t;
            dist[j][i] = dist[i][j];
        }
    }
    let mut trial = 0;
    let mut ndist = dist.clone();
    while let Err((col, p, seen)) = check(n, &dist) {
        //eprintln!("col = {}\n", col);
        let mut rest = 0;
        for i in 0..n - 1 {
            rest += dist[p[i]][p[i + 1]];
        }
        let mut nw;
        let mut nidx;
        let mut ntrial = 0;
        let mut u;
        let mut v;
        loop {
            ntrial += 1;
            if ntrial < 2 * n {
                nidx = (nxt() as usize % (n - 1)) as usize;
                u = p[nidx];
                v = p[nidx + 1];
                nw = (nxt() % W) + 1;
                if seen.contains(&(nw + rest - dist[u][v])) { continue; }
            } else {
                u = nxt() as usize % n;
                v = nxt() as usize % (n - 1) + 1 + u;
                v %= n;
                nw = (nxt() % W) + 1;
            }
            ndist[u][v] = nw;
            ndist[v][u] = nw;
            let newcol = if let Err((col, _, _)) = check(n, &ndist) {
                col
            } else {
                0
            };
            if newcol >= col {
                ndist[u][v] = dist[u][v];
                ndist[v][u] = dist[u][v];
                continue;
            }
            break;
        }
        dist[u][v] = nw;
        dist[v][u] = dist[u][v];
        trial += 1;
    }
    /*
    for i in 0..n {
        for j in 0..n {
            dist[i][j] *= 10;
        }
    }
    for i in 0..n {
        dist[i][n] = 1;
        dist[n][i] = 1;
    }
    let n = n + 1;
     */
    for i in 0..n {
        for j in 0..n {
            puts!("{}{}", dist[i][j], if j + 1 == n { "\n" } else { " " });
        }
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}
