solved P1
solved P2
solved P3
refactorred production code: applied usage of generics