Getting segmentation fault in matrix_queries

https://hack.codingblocks.com/contests/c/473/813
please help me with this problem my code getting segmentAtion fault- https://ide.codingblocks.com/#/s/14322