It's not clear; the flanking rules are somewhat self-contradictory.
The optional flanking rule is described on DMG p. 251 (with an image demonstrating it on the previous page):
A creature can’t flank an enemy that it can’t see. A creature also can’t flank while it is incapacitated. A Large or larger creature is flanking as long as at least one square or hex of its space qualifies for flanking.
Flanking on Squares. When a creature and at least one of its allies are adjacent to an enemy and on opposite sides or corners of the enemy’s space, they flank that enemy, and each of them has advantage on melee attack rolls against that enemy.
When in doubt about whether two creatures flank an enemy on a grid, trace an imaginary line between the centers of the creatures’ spaces. If the line passes through opposite sides or corners of the enemy’s space, the enemy is flanked.
One interpretation
If you take the "when in doubt" description as the rule, then neither of the Medium creatures are flanked; a line going from the center of each Large creature's space doesn't go through opposite corners/sides of either Medium creature's space. In order for one of the two Medium creatures to be flanked, one of the two Large creatures must move one square north or south (per the image); only one of the two Medium creatures would be flanked at a time.
As such, the situation you describe can never really happen - I don't think the positioning required would allow more than one creature to be flanked by the same pair of enemies.
A contradictory interpretation
However, the rest of the description of flanking in those previous 2 paragraphs says that:
A Large or larger creature is flanking as long as at least one square or hex of its space qualifies for flanking.
And the definition of what qualifies for flanking could be taken from the next paragraph:
When a creature and at least one of its allies are adjacent to an enemy and on opposite sides or corners of the enemy’s space, they flank that enemy
That requirement is certainly met by the parallel quadrants of the Large creatures (e.g. the northeast quadrant of Large creature A and the northwest quadrant of Large creature B). It could reasonably be argued that both Large creatures flank both Medium creatures, because both Large creatures have a square of controlled space that matches a square of the other's controlled space and qualifies for flanking each Medium creature.
If that's the correct/intended interpretation, then there's nothing in the rules that would suggest that the advantage from flanking is canceled out simply because there are multiple flanked enemies.
Reconciling the two
Ultimately, it's up to DM discretion. The optional flanking rule in 5e is somewhat poorly designed, even setting this contradiction aside (it's trivial to move around an enemy but stay within its reach if you don't provoke opportunity attacks while doing so). If you're the DM, I simply recommend you adjudicate the rule in a way that makes the most sense to you.