4. Determine all complex numbers $z$ and $w$ such that

$$
|z|^{2}+z w+\bar{w}=2+6 i \quad \text { and } \quad|w|^{2}+\overline{z w}+z=2-4 i .
$$
4. Since $|z|^{2}=z \bar{z}$ and $|w|^{2}=w \bar{w}$, by adding the given equations we get

$$
\begin{aligned}
4+2 i & =z \bar{z}+z w+w \bar{w}+\overline{z w}+z+\bar{w}=z(\bar{z}+w)+\bar{w}(\bar{z}+w)+z+\bar{w} \\
& =(z+\bar{w})(\bar{z}+w)+z+\bar{w}=|z+\bar{w}|^{2}+z+\bar{w}
\end{aligned}
$$

Let $z+\bar{w}=a+b i$, where $a, b \in \mathbb{R}$. Then from the last equation we get $a^{2}+b^{2}+a+b i=4+2 i$, which implies $b=2$ and then $a^{2}+a=0$. Therefore, $a=0$ or $a=-1$.

First, consider the case $a=0$. Then we have $z+\bar{w}=2 i$, so substituting $\bar{w}=2 i-z$ and $w=\overline{2 i-z}=-2 i-\bar{z}$ into the first equation we get

$$
2+6 i=|z|^{2}+z(-2 i-\bar{z})+2 i-z=2 i-z(1+2 i)
$$

From this, we get $z=\frac{2+4 i}{-(1+2 i)}=-2$ and $w=2-2 i$.

Now, let $a=-1$. Then we have $z+\bar{w}=-1+2 i$, so substituting $\bar{w}=-1+2 i-z$ and $w=\overline{-1+2 i-z}=-1-2 i-\bar{z}$ into the first equation we get

$$
2+6 i=|z|^{2}+z(-1-2 i-\bar{z})-1+2 i-z=-1+2 i-z(2+2 i)
$$

From this, we get $z=\frac{3+4 i}{-(2+2 i)}=\frac{(3+4 i)(2-2 i)}{-8}=\frac{6-6 i+8 i+8}{-8}=-\frac{7+i}{4}$ and $w=\frac{3-9 i}{4}$.

Therefore, there are two solutions: $(z, w)=(-2,2-2 i)$ and $(z, w)=\left(-\frac{7+i}{4}, \frac{3-9 i}{4}\right)$.