A composition works in the following way:
So using this we see that the value of the f domain gives a value in the range f range that is searched in the g domain to get the value in the g range.
So let's begin with 0 in the f domain, and send us to 0 in the f range. Then we search 0 in the g domain and send us to 8. So 0 is part of the composition domain and 8 is part of the composition range.
Now with 1 in the f domain, send us to 5 in the f range. Then we search 5 in the g domain but doesn't exist, so it's not part of the solution.
Let's use only the values available in the g domain (4 and 8) to search in the f range.
4 in the f domain, send us to 4 in the f range. Then we search 4 in the g domain and send us to 8. So 4 is part of the composition domain and 8 is part of the composition range.
Finally, we see that 8 is not in the f range so we finish.
Answer: Domain=0,4 Range=8