This disclosure relates to novel tricyclic pyrimidine compounds and tricyclic pyridine compounds having JAK inhibitory activities. A tricyclic heterocyclic compound represented by the formula (Ib), wherein the rings Ab and Bb, Xb, Yb, R1b, R2b, R3b, L1b, L2b, L3b and nb are as defined in the specification.