  We determine the spaces of states of the two-dimensional $O(n)$ and $Q$-state
Potts models with generic parameters $n,Q\in \mathbb{C}$ as representations of
their known symmetry algebras. While the relevant representations of the
conformal algebra were recently worked out, it remained to determine the action
of the global symmetry groups: the orthogonal group for the $O(n)$ model, and
the symmetric group $S_Q$ for the $Q$-state Potts model.
  We do this by two independent methods. First we compute the twisted torus
partition functions of the models at criticality. The twist in question is the
insertion of a group element along one cycle of the torus: this breaks modular
invariance, but allows the partition function to have a unique decomposition
into characters of irreducible representations of the global symmetry group.
  Our second method reduces the problem to determining branching rules of
certain diagram algebras. For the $O(n)$ model, we decompose representations of
the Brauer algebra into representations of its unoriented
Jones--Temperley--Lieb subalgebra. For the $Q$-state Potts model, we decompose
representations of the partition algebra into representations of the
appropriate subalgebra. We find explicit expressions for these decompositions
as sums over certain sets of diagrams, and over standard Young tableaux.
  We check that both methods agree in many cases. Moreover, our spaces of
states are consistent with recent bootstrap results on four-point functions of
the corresponding CFTs.
