BRST cohomology of Yang-Mills gauge fields in the presence of gravity in Ashtekar variables