let rec take n = function
  | [] -> []
  | h :: t ->
      if n = 0
      then []
      else h :: take (n - 1) t

let rec drop n = function
  | [] -> []
  | (_ :: t) as l ->
      if n = 0
      then l
      else drop (n - 1) t

let () = Scanf.scanf "%d" @@ fun n ->
  let lv = Array.make_matrix n n 0 in
  let rec solve l vs = function
    | 0 | 1 -> ()
    | n ->
        let bs = take (n / 2) vs in
        let ws = drop (n / 2) vs in
        List.iter (fun b ->
          List.iter (fun w ->
            lv.(b).(w) <- l;
            lv.(w).(b) <- l) ws) bs;
        solve (l + 1) bs (n / 2);
        solve (l + 1) ws ((n + 1) / 2) in
  solve 1 (Array.to_list (Array.init n (( + ) 0))) n;
  for i = 0 to n - 1 do
    for j = i + 1 to n - 1 do
      Printf.printf "%d " lv.(i).(j)
    done;
    print_newline ()
  done

