# eliminate left recursion of below grammar

Please look at this grammar: $$𝑆 → 𝑆𝐴𝐵 \ | \ 𝐴𝑏 \ | \ 𝑏 \\ 𝐴 → 𝑆𝐵 \ | \ 𝑎 \ | \ 𝐵𝑆 \\ 𝐵 → 𝐴𝑆 \ | \ d$$

I eliminated B from the grammar and it converted to:

$$S → SAAS \ | SAd \ | \ Ab | \ b \\ A → SAS \ | \ Sd \ | \ a \ | ASS \ | dS$$

But I can't eliminate loop recursion between A and S.Was it a good solution I removed the B at first? How can I solve that?

any help is much appreciated.

$$𝑆 → YX \ | \ Y \\ Y → Ab \ | \ b \\ X → ABX \ | \ AB \\ A → SB \ | \ BS \ | \ a \\ 𝐵 → 𝐴𝑆 \ | \ d$$