Relegious people

i done this ques by dfs but my only 1 test case is passing in all other it is showing tle so please help me out of this