Let $x,$ $y,$ and $z$ be nonnegative real numbers such that $x + y + z = 3.$  Find the maximum value of
\[(xy + z)(xz + y).\]
<|im_start|>system
You are a helpful assistant.<|im_end|>
<|im_start|>user
Let $x,$ $y,$ and $z$ be nonnegative real numbers such that $x + y + z = 3.$  Find the maximum value of
\[(xy + z)(xz + y).\]
Please reason step by step, and put your final answer within \boxed{{}}.<|im_end|>
<|im_start|>assistant

user
4
Let $x,$ $y,$ and $z$ be nonnegative real numbers such that $x + y + z = 3.$  Find the maximum value of
\[(xy + z)(xz + y).\]
train