If the average of 4 and x is equal to the average of 2, 8, and x, what is the value of x?