you give m x n binary grid 1 represent brick 0 represent space a brick stable ifit directly connect grid orat brick adjacent cell stableyou give array hit sequence erasure want apply each time want erase brick location hitsi rowi coli the brick location exist disappear some brick long stable erasure fall once brick fall immediately erase grid ie land stable bricksreturn array result resulti number brick fall ith erasure appliednote erasure refer location brick brick drop Example 1input grid 10001110 hit 10output 2explanation start grid1000 1110we erase underline brick 10 result grid1000 0110the underlined brick long stable long connect adjacent stable brick fall the result grid is1000 0000hence result 2example 2Input grid 10001100 hit 1110output 00explanation start grid1000 1100we erase underline brick 11 result grid1000 1000all remain brick stable brick fall the grid remain same1000 1000next erase underline brick 10 result grid1000 0000once remain brick stable brick fallhence result 00 Constraintsm gridlengthn gridilength1 m n 200gridij 0 11 hitslength 4 104hitsilength 20 xi m 10 yi n 1all xi yi unique