There is nothing in Islam that allows a husband and wife to agree that neither will inherit from the other.
This is outside of Islam. In Islam, the husband—
You have half of what your wives leave if they have no child, but if they have a child, you get a quarter. And they have a quarter of what you leave if you have no child, but if you have a child, they get an eighth. There is nothing—
That she makes it a condition that you do not inherit from her, or he makes it a condition that she does not inherit from him.
This condition has no value, even if they write it down and stamp it with their hands and feet.
Even if all the people in the mosque witness it, when one of them dies and the judge is presented with this condition, he will tear it up.
And he throws it away, saying to you, "It has no value." The condition is invalid.