Initially, Liquid A = 21 litres

Say, initially amount of liquid A= X, and amount of liquid B = Y then,

X/(X+Y) = 7/12 => 12X= 7X+7Y => 5X=7Y

After drawing 9 litres of mixture and fillinf with 9 litre of liquid B;

(X-(7/12)(9))/(Y-(5/12)(9)+9) = 7/9

Solving, we get => (4X-21)/(4Y+21) = 7/9 => 36X-189=28Y+147 => 36X-28Y=336 => 9X-7Y = 84,

but, as we know, X=7Y/5, replacing we get => 9*7Y/5 - 7Y = 84 ==> 63Y-35Y = 420 ==> Y= 420/28 = 15

Hence, X=7*15/5 = 21