Design an undo system that supports tagging commands and selective undo by tag. You must implement a class UndoSystem with the following API:
execute(command: str, tags: Set[str]) -> None
Append the command to the history along with its associated tags. Tags are arbitrary strings; a command may have zero or more tags.
undo_by_tag(tag: str) -> Optional[str]
Undo the most recently executed command that (1) contains the given tag and (2) has not already been undone. Return the command string that was undone, or None if no such command exists. Undoing a command marks it as “undone” but keeps it in the log so that later undos can skip it.
redo() -> Optional[str]
Re-execute the last command that was undone by any undo operation (regardless of tag). Return the command string that was redone, or None if nothing is eligible for redo.
All operations must run efficiently even when the number of commands and tags is large.