def reversed_index(child_num_cols, join_conditions):
    """ Return reverse index of join_conditions.
        r_index[i][j] -> k, j-th column of i-th child is in k-th
        join conditions, if the column is not joined, its r_index value will
        be -1
    """
    # make it -1 first
    r_index = [[-1] * num_cols for num_cols in child_num_cols]
    for i, jf_list in enumerate(join_conditions):
        for jf in jf_list:
            r_index[jf[0]][jf[1]] = i
    return r_index