Memory for RouterChain

I want to create RouterChain with memory. The router chain routes to python,math-llm,wikipedia agents and llmchain.
Use case:
User: explain mergesort.
AI: router routed it to wikipedia or default llm and explained the algorithm.
User: Code me the algorithm
AI: Now it should have memory to know what algorithm it explained before. And Now using python agent it should code it.

Any Suggestions how to do it?