The present invention is directed to novel pyrazolopyrimidines such as compounds of Formula I, their derivatives, pharmaceutically acceptable salts, solvates and hydrates thereof. The compounds and compositions of the present invention have protein kinases inhibitory activities against BTK and/or EGFR T790M and are useful for the treatment of protein kinases mediated diseases and conditions.