First, take all elements modulo $$$2$$$. Now all elements are ones and zeros. It can be noticed that if we remove all $$$a_i$$$ that are equal to zero, then $$$S_v$$$ for the remaining vertices does not change. Remove all $$$a_i$$$ equal to zero whose initial $$$S_v$$$ is odd; if $$$S_v$$$ is zero, then there is no answer. Those vertices $$$v$$$ whose $$$S_v$$$ is even are removed as the ones are removed.
Now we need to deal with the ones. Remove all vertices $$$v$$$ with $$$a_v = 0$$$ from the graph, leaving a forest (a graph of several disconnected trees) of ones. Solve the problem for each new tree of ones. For a tree of ones of size $$$n$$$, there is no answer when $$$n$$$ is even. When $$$n$$$ is even, the number of edges is odd, but each removal deletes one vertex and an even number of edges. Subtracting even numbers from the initial odd number of edges, we will never reach zero edges (i.e., an empty graph). Now we claim that when $$$n$$$ is odd, an answer always exists.
Let us say that for a pair of adjacent vertices $$$(v, u)$$$, vertex $$$v$$$ contributes to $$$u$$$ if after removing $$$u$$$, the component containing vertex $$$v$$$ becomes even-sized. Denote $$$f(v)$$$ as the number of vertices contributing to $$$v$$$. It can be understood that we need to delete a vertex with $$$f(v)=0$$$. The components of all neighbors of such a vertex are odd-sized, and to obtain an odd $$$n$$$, we need it to have an even number of neighbors (so we can delete it from the graph uniquely). Now it is claimed that such a vertex always exists.
ProofConsider some edge $$$(v, u)$$$ in the tree. Since $$$n$$$ is odd, either $$$v$$$ contributes to $$$u$$$ or $$$u$$$ contributes to $$$v$$$. Therefore, the sum of all $$$f(v)$$$ equals $$$n-1$$$, and by the pigeonhole principle there exists a vertex with $$$f(v)=0$$$, which is what we needed to prove.
It can be noticed that after deleting vertex $$$v$$$, values of $$$f$$$ change only for neighbors of $$$v$$$. For all neighbors $$$u$$$ of vertex $$$v$$$, the value $$$f(u)$$$ decreases by $$$1$$$, because the contribution was from $$$v$$$ to $$$u$$$. We compute all values of $$$f$$$ once, and using BFS we delete vertices with $$$f=0$$$. We also should not forget that some zeros need to be deleted as ones are removed. This solution runs in $$$O(n)$$$ operations.