Pseudorapidity and transverse momentum dependence of flow harmonics in pPb and PbPb collisions