speed up get_id with lookup[][] in count_ways