6. On the sides $A B$ and $A C$ of an acute-angled triangle $A B C$, two equal rectangles $A M N B$ and $A P Q C$ are constructed outwardly. Find the distance between the vertices $N$ and $Q$ of the rectangles, if the lengths of the sides $A B$ and $A C$ are $2 \sqrt{2}$ and 1, respectively, and the angle at vertex $A$ of the triangle is $45^{\circ}$.
Answer: $3 \sqrt{2+\sqrt{2}}$.

#