input: Write a python function to generate the gamma matrix for a given parent array and number of nodes.
  assert generate_gamma_matrix([1, 1, 2, 3], 4) == [[1, 1, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 1]]
  assert generate_gamma_matrix([1, 2, 3, 3], 5) == [[1, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 1, 1, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]
  assert generate_gamma_matrix([2, 2, 2], 3) == [[1, 0, 0], [1, 1, 1], [0, 0, 1]]
output: def generate_gamma_matrix(parent, n):
      gamma_matrix = [[0] * n for _ in range(n)]
      for i in range(n):
          for j in range(i + 1):
              if j == i or parent[i] <= j + 1:
                  gamma_matrix[j][i] = 1
      return gamma_matrix