12. As shown in Figure 2, given a circle $\odot O$ with radius $R$ and a line $l$ outside $\odot O$, the projection of $O$ on $l$ is $H$, $O H=d$, and $O H$ intersects $\odot O$ at points $C$ and $D$, with $C H > D H$. Let $P$ and $Q$ be points on $l$, both on the same side of $H$, and $P H = a$, $Q H = b (a > b)$. In $\odot O$, there are 2008 chords $A_{i} B_{i} (i=1,2, \cdots, 2008)$ parallel to $l$, and these 2008

chords intersect $C D$ at points that divide $C D$ equally. Then
$$
\frac{1}{2008} \sum_{i=1}^{2008}\left(P A_{i}^{2}+P B_{i}^{2}+Q A_{i}^{2}+Q B_{i}^{2}\right)
$$

is equal to $\qquad$ (expressed in terms of $a, b, d, R$).
$$
12 \cdot 2 a^{2}+2 b^{2}+4 d^{2}+4 R^{2} \text {. }
$$

Let the midpoint of $A_{i} B_{i}$ be $M_{i}$, and the midpoint of $P Q$ be $N$. By the median formula, we have
$$
\begin{array}{l}
P A_{i}^{2}+P B_{i}^{2}+Q A_{i}^{2}+Q B_{i}^{2} \\
=P Q^{2}+A_{i} B_{i}^{2}+4 M_{i} N^{2} \\
=(a-b)^{2}+A_{i} B_{i}^{2}+4 M_{i} N^{2} .
\end{array}
$$

Since $M_{i}$ lies on $C H$, let $O M_{i}=x_{i}$, where, assuming when $M_{i}$ is on $O D$, $x_{i}$ takes a positive value, and when $M_{i}$ is on $O C$, $x_{i}$ takes a negative value. Then
$$
\begin{array}{l}
A_{i} B_{i}^{2}+4 M_{i} N^{2}=A_{i} B_{i}^{2}+4\left(H N^{2}+M_{i} H^{2}\right) \\
=4\left(R^{2}-x_{i}^{2}\right)+4\left[\left(\frac{a+b}{2}\right)^{2}+\left(d-x_{i}\right)^{2}\right] \\
=(a+b)^{2}+4 R^{2}+4 d^{2}-8 d x_{i} .
\end{array}
$$

Since $\sum_{i=1}^{2008} x_{i}=0$, we have
$$
\begin{array}{l}
\frac{1}{2008} \sum_{i=1}^{2008}\left(P A_{i}^{2}+P B_{i}^{2}+Q A_{i}^{2}+Q B_{i}^{2}\right) \\
=2 a^{2}+2 b^{2}+4 d^{2}+4 R^{2} . \\
\text { Note: } P A_{i}^{2}+P B_{i}^{2}+Q A_{i}^{2}+Q B_{i}^{2}=P Q^{2}+A_{i} B_{i}^{2}+
\end{array}
$$
$4 M_{i} N^{2}$ is Euler's theorem.