PRoblem in FIND IT - number theory

when i executed first time it was giving tle but next time no output was given by compiler
also tell me why it is giving tle
according to me its complexity is O(nlogn)