Runtime error on SPOJ - LCA

the LCA problem on SPOJ. I keep getting runtime error with both depth approach and euler tour approach. Below is my code based on binary lifting and depth approach. Please help.

Code:
https://ide.geeksforgeeks.org/NGX6v0fe0w