1. Every parent or other person legally responsible for the care or support of a child who wholly abandons the child or willfully fails to furnish food, shelter, clothing, and medical attention reasonably necessary and sufficient to meet the child’s needs is guilty of a class C felony.2. Any food, shelter, clothing, or medical attention furnished by or through a welfare or charitable program of any governmental agency, civic or religious organization, or a combination thereof, or any intervening third party, on the basis of need, does not avoid, excuse, relieve, or discharge either parent or person legally responsible for care and support of a child from the criminal penalty for the willful failure or neglect to provide such support.3. A parent is not relieved, excused, or discharged from the responsibility and criminal penalty provided in this section if the other parent is providing the child with care and support unless the parents reside together.4. The fact, if it is a fact, that either parent may have secured a divorce awarding the custody of the child, in no manner relieves either parent from the requirements and penalty of this section, except that compliance with the terms of a child support order by a parent is an affirmative defense to a charge under this section made against that parent.5. If the parent or other person legally responsible for the care or support of a child, while in another state and while the minor child is in this state, wholly abandons the child or willfully fails to furnish food, clothing, shelter, and medical attention reasonably necessary and sufficient to meet the child’s needs, the failure must be construed to have been committed in this state and all of the laws of this state with reference to punishment apply with the same force and effect as if the abandonment and failure to support had occurred in this state.6. For purposes of this section, “willfully” has the meaning provided in section 12.1-02-02.