捨てる神あれば拾う神あり(すてるかみあればひろうかみあり)

Japanese vocabulary

Meaning: when one door is shut, another is open; the world is as kind as it is cruel; there are gods that will abandon you and there are gods that will pick you up

See it used in real works