Alice and Bob are playing a game as follows:

Initially

- There're two subgroups $A,B$ of Sym(n) known to both Alice and Bob
- There're $n$ slots $S_1, \cdots, S_n$ and $n$ boxes $B_1, \cdots, B_n$. Initially $i$-th box is on $i$-th slot.
- On each box, Bob secretly writes an element of $A$ and closes the lid (the element is not known to Alice). An element of $A$ can appear in multiple/no box.

At each step:

- Alice picks a subset $S$ of $S \subset \{1, 2, \cdots, n \}$, and an element $a \in A$, and tells Bob $S$ and $a$.
- For each $i \in S$, Bob replaces the element $x \in A$ written on the box on $S_i$ with $xa$.
- If after the previous step the element in all the boxes is the identity element then the game is over and Bob informs Alice that he won the game.
- Bob picks an element (this element is not known to Alice) $\pi \in B$ and for all $i \in \{1, 2, \cdots, n \}$ simultaneously moves the box in $S_i$ to $S_{\pi(i)}$.

Given $(A,B)$, determine whether Alice has a winning strategy or not. (Alice wins if there's a constant $c$ such Alice is guaranteed to win under $c$ moves, no matter how Bob plays)

For the particular case $(A,B) = (\mathbb{Z}_2, \mathbb{Z}_4)$ we get the following "folklore" problem (wording taken from Peter Winkler's book):

[Spinning switches] Four identical, unlabeled switches are wired in series to a light bulb. The switches are simple buttons whose state cannot be directly observed, but can be changed by pushing; they are mounted on the corners of a rotatable square. At any point, you may push, simultaneously, any subset of the buttons, but then an adversary spins the square. Show that there is a deterministic algorithm that will enable you to turn on the bulb in at most some fixed number of steps.

I'm unable to solve the general problem (except for a very few almost trivial special cases like above), any ideas how to solve this ? The proof of the above puzzle can be adapted to show that $(\mathbb{Z}_2, \mathbb{Z}_n)$ is winnable iff $n$ is a power of 2.