private void solve() throws IOException {
    int rows, cols;
    while ((rows = nextInt()) != 0 && (cols = nextInt()) != 0) {
      int[] board = readBoard(rows, cols);
      int tiles = solveBoard(rows, cols, board);
      if (tiles == -1) {
        out.format("Damaged billboard.%n");
      } else {
        out.format("You have to tap %d tiles.%n", tiles);
      }
    }
  }