Lowest Common Ancestor

SPOJ - LCASQ