Inverse electrostatic and elasticity problems for checkered distributions