Working Mealy Machine