When the switch S is closed, the two capacitors in parallel will be charged by the same potential difference V.
So, charge on capacitor C
q1 = C1V = 1 × 6 = 6 mC
q2 = C2 V = 1 × 6 = 6 mC
q = q1 + q2 = 6 + 6 = 12 mC.
When switch S is opened and dielectric is introduced. Then

Capacity of both the capacitors becomes K times
i.e., C’1 = C’2 = KC = 3 × 1 = 3 mF
Capacitor A remains connected to battery
∵ V’1 = V = 6 V
q’1 = Kq = 3 x 6 mC = 18 m C
Capacitor B becomes isolated
∵ q’2 = q2 or C’2 V’2 = C2V2 or (KC)V’2 = CV
V'2 = v/k = 6/3 =2v