A corporation, trust, or community chest, fund, or foundation—
(A) created or organized in the United States or in any possession thereof, or under the law of the United States, any State, the District of Columbia, or any possession of the United States;
(B) organized and operated exclusively for religious, charitable, scientific, literary, or educational purposes, or to foster national or international amateur sports competition (but only if no part of its activities involve the provision of athletic facilities or equipment), or for the prevention of cruelty to children or animals;
(C) no part of the net earnings of which inures to the benefit of any private shareholder or individual; and
(D) which is not disqualified for tax exemption under section 501(c)(3) by reason of attempting to influence legislation, and which does not participate in, or intervene in (including the publishing or distributing of statements), any political campaign on behalf of (or in opposition to) any candidate for public office.
A contribution or gift by a corporation to a trust, chest, fund, or foundation shall be deductible by reason of this paragraph only if it is to be used within the United States or any of its possessions exclusively for purposes specified in subparagraph (B). Rules similar to the rules of section 501(j) shall apply for purposes of this paragraph.