FIELD: medicine, pharmaceutics.SUBSTANCE: invention relates to novel N-containing heteroaryl derivatives of formula I or II or their pharmaceutically acceptable salts, which possess properties of JAK kinase, in particular JAK3, and can be applied for treating such diseases as asthma and chronic obstructive pulmonary disease (COPD). In formulae A represents carbon and B represents nitrogen or A represents nitrogen and B represents carbon; W represents CH or N; R1 and R2, independently represent hydrogen, C1-4alkyl, halogenC1-4alkyl, -CN; R3 represents C1-4alkyl, R9-C1-4alkyl, Cy1, where Cy1 is optionally substituted with one or several substituents R10; R4 represents hydrogen, C1-4alkyl, R12R7N-C0alkyl, where one of R7 and R12 represents hydrogen, and the other represents C1-4alkyl or group R13, which is selected from C1-5alkyl, Cy2-C0alkyl; R5 represents hydrogen; R6 represents hydrogen, C1-4alkyl, C1-4alkoxyC1-4alkyl, hydroxyC1-4alkyl, R12R7N-C1-4alkyl, R16CO-C0alkyl, Cy1; R7 represents hydrogen or C1-4alkyl; R9 represents halogen, -CN, -CONR7R12, -COR13, CO2R12, -OR12, -SO2R13, -SO2NR7R12, -NR7R12, -NR7COR12; R10 represents C1-4alkyl or R9-C0-4alkyl; R11 represents C1-4alkyl, halogen, -CN, -NR7R14; R12 represents hydrogen or R13; R13 represents C1-5alkyl, hydroxyC1-4alkyl, cyanoC1-4alkyl, Cy2-C0alkyl or R14R7N-C1-4alkyl; where Cy2 is optionally substituted with one or several constituents R11; R14 represents hydrogen or C1-4alkyl; R16 represents C1-4alkyl, halogenC1-4alkyl, C1-4alkoxyC1-4alkyl, hydroxyC1-4alkyl or cyanoC1-4alkyl; Cy1 represents monocyclic carbocyclic unsaturated or saturated ring, selected from C3-C6cycloalkyl, phenyl, or saturated monocyclic 4-6-membered heterocyclic ring, containing from 1 to 2 heteroatoms, selected from N and S, or partially unsaturated 10-membered bicyclic heterocyclic ring, containing oxygen atom as heteroatom, which can be substituted with group R11, where said ring is bound with the remaining part of molecule via any avail