Here's BAA with the variable A in the middle and then two which is the index, and then there's another production that's the same but without the capital A. And here is the grammar for the second strings in the pair with start symbol B. As an example if we choose the three pairs in order one, two, three then there is a derivation from A that looks like this. 