Entanglement of three quantum memories via interference of three single photons