Anomaly-safe discrete groups