cellular automaton in cpp, reading rules from stdin