Your answers might be wrong because judge is using 1 based indexing and not 0 based, so to check valid position check
i>0 && i<=A && j>0 && j<=B
you might be doing i> =0 && i<A like this
Your answers might be wrong because judge is using 1 based indexing and not 0 based, so to check valid position check
i>0 && i<=A && j>0 && j<=B
you might be doing i> =0 && i<A like this