Memory Shapes Generational Teaching