It appears that there are several variants of this problem that appeared in classical texts.
This form of the problem is from 《仙机武库》 and titled 金印 (jin1 yin4, ancient golden coin).
Two variants appear in the Xuanxuan Qijing.
See Xuanxuan Qijing Problem 33 and Xuanxuan Qijing Problem 191.
Solution