To begin with it's a well known result in gravitation that the sphere has geometry such that for gravitational calculations all it's mass can be considered to be concentrated at its centre for objects outside of its radius.

Second there is another result that states that if inside a spherical shell then there is no gravitational influence i.e. net gravitational force on an obejct there is zero. This can be easily shown using geometry since the force on either side is proportional to

and the area subtended on either side is proportional to

. Hence the forces cancel and so within the cavity the net contribution is zero.

Now consider a solid sphere of radius

with a 'tunnel' of negligible width (compared to the size of the sphere) going into the sphere along a diameter. At any point at radius

,

, in this tunnel the gravitational influence can be considered to be the sum of that of a spherical shell with inner radius

and a solid sphere of radius r. As already explained the shell then has zero contribution and the influence of the inner sphere on a mass

is then

. (Gravitational force inside a sphere)
Ok, so now we know this how do we use this result for this punctured sphere?

Well, this is the equivalent to whatever the net gravitational effect of the large sphere (radius

) minus the net gravitational effect of the small sphere (radius

).

I'll call the big solid sphere A and the small one B so then the net graviational force will be:

.

We know the net force will be towards A so let us define the force in the direction of BA as the positive direction and let x be the distance of our mass m along AB from point B. Hence from the above result we have that

and

so that

.

This means this is a constant acceleration problem and since the sphere is fixed we can simply use

to find that the velocity at impact at A is:

i.e.

.