Hi,
Click on the Manage-->Top Level Security->All Folders and for Everyone group set the View access and in advance tab unchecked the "Inherit from parent folder" & Inherit from parent group" option.With this you can see the everyone group has View access on the "All Folders" and for all other sub folders everyone group has no access.
After that all user groups can see the All Folders (Root folder).
Click on the Folder A and assign user group A on this folder and assign access level.Similar to this click on Folder B and assign user B and access level.
Amit