you give 2D integer grid size m x n integer x in operation add x subtract x element gridA univalue grid grid element equalreturn minimum number operation grid univalue if possible return 1 example 1input grid 2468 x 2output 4explanation we element equal 4 follow Add x 2 Subtract x 6 Subtract x 8 twicea total 4 operation usedexample 2input grid 1523 x 1output 5explanation we element equal 3example 3input grid 1234 x 2output 1explanation it impossible element equal Constraintsm gridlengthn gridilength1 m n 1051 m n 1051 x gridij 104