This question was asked in Example 17
Check the way of solving it is wrong 

Due to a special case you got the answer right

Check gof and fog
Himanshu Tiwari's image