The present invention relates to the new pyrimidines and pyridine compounds or its pharmaceutically acceptable salt of formula (I), wherein R1, R2, R3, R4, R5, X, Y and G are defined as in the description, and be related to the pharmaceutical composition containing them, prepare they method and they treatment to inhibit FGFR have response disease such as cancer in purposes.本發明涉及式(I)的新的嘧啶和吡啶化合物或其藥學上可接受的鹽,其中R1、R2、R3、R4、R5、X、Y和G如說明書中所定義,並且涉及含有它們的藥物組合物、製備它們的方法和它們在治療對抑制FGFR有響應的疾病例如癌症中的用途。