static void process() {
		int i, j;

		// we initialize every element in P with -1
		for (i = 0; i < nodes; i++)
			for (j = 0; 1 << j < nodes; j++) {
				P[i][j] = -1;
				M[i][j] = 0;
			}

		// the first ancestor of every node i is T[i]
		for (i = 0; i < nodes; i++) {
			P[i][0] = T[i];
			M[i][0] = H[i];
		}

		// bottom up dynamic programming
		for (j = 1; 1 << j < nodes; j++)
			for (i = 0; i < nodes; i++)
				if (P[i][j - 1] != -1) {
					P[i][j] = P[P[i][j - 1]][j - 1];
					M[i][j] = Math.max(M[i][j - 1], M[P[i][j - 1]][j - 1]);
				}
	}