private static int[][] prepare(int length1, int length2) {
    int[][] d = new int[length1 + 1][length2 + 1];
    for (int i = 0; i <= length1; i++) d[i][0] = i;
    for (int j = 0; j <= length2; j++) d[0][j] = j;
    return d;
  }
private static int[][] prepare(int length1, int length2)