6. Given the sets $A=\{(x, y) \mid a x+y=1, x, y \in Z\}, B=\{(x, y) \mid x$ $+a y=1, x, y \in Z\}, C=\left\{(x, y) \mid x^{2}+y^{2}=1\right\}$, find the value of $a$ when $(A \cup B) \cap C$ is a four-element set.
6. Set $A$ is the set of lattice points on the line $a x+y=1$, and set $B$ is the set of lattice points on the line $x+a y=1$. Set $C$ consists of only four lattice points: $(1,0)$, $(-1,0)$, $(0,-1)$, and $(0,1)$. Since $(A \cup B) \cap C=(A \cap C) \cup(B \cap C)$ is a four-element set, and $A \cap C$ and $B \cap C$ are each sets with at most two elements, it follows that $A \cap C$ and $B \cap C$ each have two elements, and $(A \cap C) \cup(B \cap C)=\{(-1,0),(1,0),(0,-1),(0,1)\}$. Therefore, the lines $a x+y=1$ and $x+a y=1$ do not coincide and cannot intersect, so $-a=-\frac{1}{a}$, and since $a \neq 1$, we get $a=-1$.