Dynamic Tree Connectivity

SPOJ - DYNACON1