How many $10$-digit positive integers containing only the numbers $1,2,3$ can be written such that the first and the last digits are same, and no two consecutive digits are same?

$ 
\textbf{(A)}\ 768
\qquad\textbf{(B)}\ 642
\qquad\textbf{(C)}\ 564
\qquad\textbf{(D)}\ 510
\qquad\textbf{(E)}\ 456
$
1. **Determine the choices for the first digit:**
   - The first digit can be any of the numbers \(1, 2,\) or \(3\). Therefore, we have 3 choices for the first digit.

2. **Determine the choices for the last digit:**
   - The last digit must be the same as the first digit. Therefore, there is only 1 choice for the last digit once the first digit is chosen.

3. **Determine the choices for the remaining digits:**
   - For the remaining 8 digits (positions 2 through 9), each digit must be different from the digit immediately preceding it. This means that for each of these positions, there are 2 choices (since there are 3 digits in total, and one is already used by the previous position).

4. **Calculate the total number of valid sequences:**
   - We have 3 choices for the first digit.
   - For each of the 8 middle positions, we have 2 choices.
   - The last digit is fixed once the first digit is chosen.

   Therefore, the total number of valid sequences is:
   \[
   3 \times 2^8
   \]

5. **Perform the calculation:**
   \[
   2^8 = 256
   \]
   \[
   3 \times 256 = 768
   \]

The final answer is \(\boxed{768}\).