Now substitute epsilon in place of B in A-> BD

So first(A) = first(D) = d, epsilon

So this means A can generate b,d, epsilon.

Now if we substitute epsilon in S->Aa then we can get first(S) = a

Note that we are not writing epsilon in first(S) because S can't generate epsilon.

Hence first(S) = {a,b,d}