let $L$ be a regular language, and let $A=\{\Sigma, Q, q_0, F, \delta\}$ be a DFA such that $L = L(A)$.
I need to prove that $$L_p=\{xy\in\Sigma^*\mid\delta(q_0, y)=p\text{ and } \delta(p, x)\in F\}$$ is regular for every $p\in Q$ by defining an automaton $A_p$.
I tried to define it like so $$A_p=\{\Sigma, Q\times Q, (p, q_0), F\times \{p\}, \delta_p\}$$ where $\delta_p$ is defined like so $$ \delta_p((q_1, q_2), \sigma) = (\delta(q_1, \sigma), q_2)\text{ if }q_1 \not\in F, \\ \delta_p((q_1, q_2), \sigma) = (q_1, \delta(q_2, \sigma))\text{ if }q_1 \in F. $$ But then I have a problem where $x=uv$, $\delta(p, u)\in F$ and $\delta(p, x)\in F$.
I thought maybe I define $A_p$ as a non-deterministic automaton and then $$\delta_p((q_1, q_2), \sigma) = \{(\delta(q_1, \sigma), q_2), (q_1, \delta(q_2, \sigma))\}.$$ However, word $z=uwv$ where $$\delta_p((p, q_0), u) = (p_1, q_0) \Longrightarrow \delta_p((p_1, q_0), w) = (p_1, p) \\ \Longrightarrow \delta_p((p_1, p), v) = (p_2, p), p_2\in F\times \{p\}$$ is accepted while it shouldn't be part of $L_p$