Well, I solved it and got the answer but I wasn't able to explain it to people. So, I was surfing the web and I came across the solution on this blog: Critical Thinking Puzzles.
So, here is the detailed step-by-step solution to the problem. Feel free to share it with your friends.