Techniques like property-based testing rely on programs called generators that produce random test inputs. When manipulating the distribution of tests that a generator outputs, it is often helpful to know which random choices result in a particular test. We present ungenerators for this purpose: they run a generator “backward,” extracting a sequence of choices from a given test. Generators and ungenerators can be defined together, with very little extra code, as part of our framework of bidirectional generators based on monadic profunctors. The resulting bidirectional programs can be used in a number of real-world scenarios to improve testing methodologies.