A Basis Theorem for a Class of Two-Way Automata