Given potentially non-disjoint sets $A_1, A_2, ... A_n$, how many subsets $S \subset \bigcup A_i$ exist where
$$|S \cap A_i| = a_i$$ for $0 < i \leq n$.
For $n = 1$, the answer is $\binom{A_1}{a_1}$
For $n = 2$, the answer is $\sum _{k=0}^{|A_1 \cap A_2|}\binom{|A_1 \cap A_2|}{k}\binom{|A_1|-|A_1 \cap A_2|}{a_1-k}\binom{|A_2|-|A_1 \cap A_2|}{a_2-k}$
However, is there a general result for a general $n$ (possibly a recurrence relation)?
Any help would be appreciated.