I have two layers which come from the same data source. The first one is a vector grid layer which contains 1km x 1km features and looks like this:

[![Grid Layer][1]][1]

The second one is the grid layer dissolved into Sub-Bains, which i.e. looks like this:

[![Sub-Basin][2]][2]

I need to select all the features from layer one which touch the borderline of each Sub-Basin of layer two from within the Sub-Basin. For example of this Sub-Basin:

[![Select][3]][3]

This has to be done for multiple (1000) Sub-Basins, so selecting them manually would be too time consuming.
To include some context: I need to identify the feature with the biggest water outflow into another Sub-Basin and for that I need to export all the features which are on the inner edge of the basin.

Is there a tool or a way this can be done? QGIS and ArcGIS are possible.

  [1]: https://i.sstatic.net/0ynyz.jpg
  [2]: https://i.sstatic.net/L0xc6.jpg
  [3]: https://i.sstatic.net/aTneJ.jpg