Pseudorapidity and transverse momentum dependence of flow harmonics in p Pb and PbPb collisions