Generalized Birthday Problem