They are all well-formed formulas! It is in fact ok to have a variable quantified within the scope of a quantifier of that same variable (as in a). For a), you simply have that the $y$ in $Ay$ is quantified by the $\forall y$, and the $y$ in $By$ is quantified by the $By$. So, it is equivalent to $(\forall y)(Ay \lor (\exists x) Bx)$.
ALso, you are allowed to have free variables in well-formed formulas, as in d). What this means is that d) is not a sentence, but it is a well-formed formula.
Finally, someone may complain that b) has an extraneous pair of sentences, but others might say that d) should have an extra pair of sentences. This actually depends on how the well-formed formulas are exactly syntactically defined in your book (not every book does it the same ... in fact many books don't put parentheses around $\forall x$ like your formulas all do). But in both cases that would be some superficial nitpicking, so I would consider both of them well-formed.