Just work from the last common chords.
for the e one
iv in e is a
then work back
from a as i, what's a fourth down? E as V
But they practically hand you that one. What's iv of e? a minor, the new key.
For D...
What's the viidim? c#dim
c# dim is the iidim of what minor key? or a whole step down... bminor
Make sure you know your scales and chords.
The basic idea is that there are chords common between two keys and you can use those to smoothly modulate between two keys. If tough to say exactly where the modulation takes place when there are a few common chords in a row.
It's kind of interesting to see which chords are the same.
Any major with I, IV, V
any minor with ii, iii, vi
dim's at vii and ii in minor
And then there are modal borrowing, etc. to make it more complicated.
A more important idea might be where they end up.
e to a is down a P5, adding one flat.
D Major to b minor is moving to the relative minor, down a m3.
And I'm getting fuzzy on when it's an official modulation, as opposed to a tonicization. Both of those have a nice big V I to take care of that though. I suppose tonicization doesn't and will stick with the original key too afterward.
The relationship between the keys is important because they couldn't get to all of them smoothly. This is why the theory teacher will get very excited when they discuss augmented chords, secondary dominants, dim seventh chords, etc. and how they can modulate to any key!
Those exercises aren't that bad. Master those. It will get worse. (Although I don't exactly like how the theory classes are set up. I doubt everyone completely masters that stuff in one pass.)