Selecting a cells connected to axis (line)

Hello, I want extract the cells which are connected to the axis (Or line you can say) I do not know the workflow to do that, It will be very helpful if anyone can give a comment. Thanks.