($n,$m)=glob<>;
/ /,push@{$_{$'+0}},$`for<>;
for$i(reverse 0..$n-1){
	$||=$%=$_{$i}eq'a';
	print$%x$|;
	$_{$_}='a'for@{$_{$i}}
}