Some amount of charge say Q1 may flow from the 22V battery to the 7V battery to charge the 2F capacitor. Q2 amount may flow from 7V battery to 22V battery. How can we say that the charges are equal unless the two capacitances are equal?
The current in a series circuit is everywhere the same. Any current that leaves the 22V battery's + terminal must also flow back into its - terminal. Same goes for the 7V battery, and all the other components in the series.