Getting WA in Matrix Queries

my code https://ide.codingblocks.com/#/s/31559
ques link https://hack.codingblocks.com/contests/c/527/813