Https://hack.codingblocks.com/contests/c/471/1244

https://hack.codingblocks.com/contests/c/471/1244
my code:https://ide.codingblocks.com/#/s/21919
only two test cases are passing of mine my output is coming right.According to me,i am not able to figure out the proper logic of this question i.e. when char is d if we have to print the solution,if no of operations of d is less than the solution of more than one queue,for which queue we have to print the solution.