QTREE2,SPOJ

getting runtime error on spoj link:SPOJ.com - Problem QTREE2
my code :svhHtv - Online C++ Compiler & Debugging Tool - Ideone.com