A more general way to construct the formula:
Suppose that you have n sets, $A_1, \cdots A_n,$ where some element may be in more that one set. An example would be to revise your original example by changing $C$ from $\{7,8\}$ to $\{6,7\}.$
Let $f(A_i)$ denote the number of distinct elements in all of the $(n-1)$ sets combined other than $A_i.$
In the revised example, where $A_1$ is set to $A = \{1,2,3,4\},$ then
$f(A_1)$ would = 3.
Let $g(A_i)$ denote the number of (presumably distinct) elements in $A_i.$
Let $h(A_i)$ denote the number of elements in $A_i$ that are also in at least one of the (n-i) sets $A_{i+1}, \cdots, A_n.$
Then the possible number of ordered pairs will be
$\sum_{i=1}^n \{f(A_i) \times g(A_i)\} - h(A_i).$
The reason that $h(A_i)$ is relevant is best visualized by example. Suppose that the original example is further refined so that $A_1 = \{1,2,5,6\}.$
Then, the normal formula $\sum_{i=1}^n \{f(A_i) \times g(A_i)\}$ would count (5,5) twice and count (6,6) three times.