import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static class P { int x,y,s; P(int x, int y, int s) { this.x=x;this.y=y;this.s=s;}} static int steps(int i, int j, int n) { boolean[][] v = new boolean[n][n]; Queue
q = new LinkedList<>();;
q.add(new P(0,0,0));
while (!q.isEmpty()) {
P p = q.remove();
if (v[p.x][p.y]) continue;
if (p.x==n-1 && p.y==n-1) return p.s;
v[p.x][p.y]=true;
if (p.x+i