Mutation results:\r\n* All patients must have molecular testing performed in a Clinical Laboratory Improvement Act (CLIA) certified lab which includes which includes KRAS and NRAS gene and exon 15 of BRAF gene (BRAF V600E mutation); patients with any known activating mutation in exon 2 (codons 12 and 13), exon 3 (codons 59 and 61) and exon 4 (codons 117 and 146) of KRAS/NRAS genes and in exon 15 (BRAFV600E mutation) of BRAF gene are not eligible Tumors must be tested and known negative for EGFR tyrosine kinase inhibitor (TKI) sensitizing mutations (EGFR exon 19 deletions, L858R, L861Q, G719X) and ALK gene rearrangements by routine Clinical Laboratory Improvement Act (CLIA)-certified clinical testing methods; negative circulating tumor DNA results alone are not acceptable; prior testing for tumor PD-L1 status is not required An EGFR exon 20 insertion mutation must be detected in the tumor tissue; patients may be enrolled in the study based on an exon 20 insertion EGFR mutation detected by any Clinical Laboratory Improvement Act (CLIA)-certified tissue assay\r\n* NOTE: Testing results are to be submitted via Medidata Rave and the study chair or delegate will review the reports Participants with known epidermal growth factor receptor (EGFR) mutations which are sensitive to available targeted inhibitor therapy (including, but not limited to, deletions in exon 19 and exon 21 [L858R] substitution mutations) are excluded For Part 2 only: Participants must also have disease with a previously diagnosed activating epidermal growth factor receptor (EGFR) mutation (includes both inhibitor sensitive primary mutations such as Exon 19 deletion and L858R, as well as marketed tyrosine kinase inhibitor [TKI] -resistant mutations such as Exon 20 insertion). Documentation of EGFR mutation eligibility by CLIA-certified laboratory (or equivalent) testing is required EGFR mutation (L858R and /or ex19del) Eligible for first-line treatment with erlotinib based on documented evidence of tumor harboring an activating EGFR mutation [exon 19 deletion or exon 21 (L858R) substitution mutation]. Non-small cell lung cancer (NSCLC) or pancreatic cancer identified by exon 19 deletions or exon 21 L858R substitution mutations Cancers with exon 20 mutations Presence of sensitizing EGFR mutations (deletion in exon 19, L858R in exon 21, G719X, and L861Q); patients with the T790M mutation will also be eligible EGFR mutations as performed on a Clinical Laboratory Improvement Amendments (CLIA) certified laboratory demonstrating EGFR exon 18 G719X, exon 20 S768I, or exon 21 L861Q. Patients with compound (also referred to as multiple mutations) will be eligible provided the non-small cell lung cancer [NSCLC] demonstrates one of these mutations) Detection of concurrent EGFR mutation with exon 20 T790M, exon 19 deletion, exon 21 L858R mutation or exon 20 insertion. Patients with compound (also referred to as multiple mutations) will be excluded if the molecular testing includes one of these mutations Documented activating EGFR mutation (Exon 19 deletion, T790M, or L858R) on tumor samples by Food and Drug Administration (FDA)-approved test Prior genotyping positive for an EGFR activating mutation (L858R, exon 19 deletion, G719X, L861Q) An EGFR sensitizing mutation must be detected in tumor tissue; specifically, patients harboring the most common mutations, deletions in exon 19 or the L858R mutation in exon 21 are eligible; other EGFR sensitizing mutations may be eligible after discussion with the principal investigator; patients may be enrolled in the study based on an activating EGFR mutation detected by a Clinical Laboratory Improvement Act (CLIA) certified tissue or plasma-based assay, but will be required to undergo a mandatory tumor biopsy during study screening Patients must have tumors that lack sensitizing EGFR mutation (e.g. exon 19 deletion or exon 21 L858R) or ALK rearrangement; if a patient has squamous histology, then EGFR and ALK testing is not required Historical confirmation that the tumor harbors an EGFR mutation known to be associated with EGFR TKI sensitivity (including G719X, exon 19 deletion, L858R, L861Q). Patients whose tumors known to harbor an exon 19 deletion or exon 21 L858R EGFR mutation must have progressed on or had intolerance to an EGFR TKI; patients whose tumors are known to harbor an ALK translocation must have progressed on or had intolerance to an ALK inhibitor Cohort 1 specific inclusion criteria: Documented EGFR exon 20 mutation by one of the following Clinical Laboratory Improvement Act (CLIA) certified tests: OncoMine Comprehensive Assay (OCA), Guardant360 Assay (using plasma), or FoundationOne Assay or by a Food and Drug Administration (FDA) approved device using cobas EGFR mutation test version (v)2 or therascreen EGFR RGQ PCt kit; eligible mutations include D770_N771insSVD, D770_N771insNPG, V769_D770insASV, H773_V774insNPH, or any other exon 20 in-frame insertion or point mutation excluding T790M Cohort 2 specific inclusion criteria: documented HER2 exon 20 mutation by a Clinical Laboratory Improvement Amendments (CLIA) certified laboratory; eligible mutations include A775_G776insYVMA, G776_V777insVC, or P780_Y781insGSP, or any other in-frame exon 20 insertion mutation or point mutation including, but not limited to, L755S, G776V, and V777L EGFR T790M mutation or any other acquired EGFR exon 20 mutation; patients with coexisting primary EGFR exon 20 and T790M mutations are eligible Documented EGFR exon 20 insertion mutation Documented HER2 exon 20 insertion mutation Patient has had previous treatment with poziotinib or any other EGFR or HER2 exon 20 insertion mutation tyrosine kinase inhibitor prior to study participation Phase 2 patients are also excluded if they had prior treatment with CK-101 or other third generation TKIs that target EGFR T790M mutation-positive NSCLC, or have evidence that the tumor harbors an exon 20 insertion mutation Tumor sample confirmed as KRAS or NRAS [codons 12 and 13 (exon 2), 59 and 61 (exon 3), and 117 and 146 (exon 4)] or BRAF [codon 600 (exon 15)] mutation positive Patients with characterized EGFR mutations that predict sensitivity to EGFR therapy, including, but not limited to exon 19 deletions and exon 21 mutations Documented evidence of somatic activating mutation in EGFR (eg, G719X, exon 19 deletion, L858R, L861Q) in a tumor tissue sample. If a tissue sample is not available, then EGFR mutation status may be determined from circulating tumor DNA obtained from a blood sample using a validated or approved test kit. Presence of exon 19 deletion or exon 21 (L858R) substitution of the EGFR gene EGFR mutation with exon 19 deletion or L858R mutation (Exon 21) or ALK rearrangement positive must have failed prior TKI therapy Incurable, advanced or metastatic/recurrent non-small cell lung cancer with EGFR activating mutations (exon 19 del, exon 21 L858R, L861Q, G718X); who have radiologic and/or clinically progressive disease on erlotinib at any point during the patient's cancer treatment as determined by the Investigator Non-small cell lung cancer (NSCLC) with an activating EGFR mutation (exon 19 deletion, L858R point mutation, or any other mutation known to be associated with EGFR TKI sensitivity); presence of an activating EGFR mutation may be documented in tumor tissue or by plasma testing if performed in a Clinical Laboratory Improvement Act (CLIA)-certified laboratory; AND Have a documented EGFR in-frame exon 20 insertion by a local test, including A763_Y764insFQEA, V769_D770insASV, D770_N771insNPG, D770_N771insSVD, H773_V774insNPH, or any other in-frame exon 20 insertion mutation. A HER2 exon 20 insertion including A775_G776insYVMA, G776_V777insVC, or P780_Y781insGSP, or any other in-frame exon 20 insertion mutation. An EGFR exon 20 insertion: A763_Y764insFQEA, V769_D770insASV, D770_N771insNPG, D770_N771insSVD, H773_V774insNPH, or any other in-frame exon 20 insertion mutation. A HER2 exon 20 insertion: A775_G776insYVMA, G776_V777insVC, P780_Y781insGSP, or any other in-frame exon 20 insertion mutation. For patients with an EGFR exon 20 insertion: have not received a TKI with activity against the specific documented EGFR exon 20 insertion. For patients with a HER2 exon 20 insertion or HER2 activating point mutation: have not received a TKI with pan-HER activity (eg, afatinib, neratinib, or dacomitinib). Have one of the following documented by a local test: an activating mutation in EGFR including exon 19 deletions or exon 21 L858R substitution (with or without T790M), or an uncommon activating mutation other than exon 20 insertion including, but not limited to, G719X (where X is any other amino acid), S768I, L861Q, or L861R. For patients with a documented EGFR exon 19 deletion or exon 21 L858R substitution: resistant to at least one prior EGFR inhibitor (eg, erlotinib, gefitinib, or afatinib). Patients with an EGFR exon 20 insertion Absence of an activating mutation (Exon 19 deletion or Exon 21 L858R mutation) in the epidermal growth factor receptor (EGFR) in the pre-treatment biopsy of the tumor. Patients with activating EGFR mutations are eligible if they have progressed following treatment with erlotinib. A pretreatment tumor biopsy must be available for analysis. If a biopsy has not been performed prior to entry, then a biopsy will be required. In cohort 2, must have one or more mutations found in KRAS exon 2, 3, or 4; NRAS exon 2, 3, or 4; BRAF codon 600; may have a concomitant EGFR ectodomain mutation, if the most prevalent EGFR ectodomain mutation does not have over a 5-fold higher allele frequency than the most prevalent KRAS/NRAS/BRAF mutation All patients must have a somatic PIK3CA gene mutation (i.e., R88Q in exon 1, N345K in exon 4, C420R in exon 7, E542K, E545X [E545A, E545D, E545G, and E545K], Q546X [Q546E, Q546K, Q546L, and Q546R] in exon 9, and M1043I, H1047X [H1047L, H1047R, and H1047Y], or G1049R in exon 20) in a representative primary or metastatic tumor sample confirmed by the Roche COBAS PIK3CA Mutation Test at Q^2 Solutions Documented evidence of a tumor with 1 or more EGFR mutations excluding exon 20\n insertion - Documented evidence of an exon 20 insertion activating mutation in the EGFR gene Presence of JAK2 exon 12 mutation Patients must have documented presence of an EGFR exon 19 deletion or exon 21 (L858R) substitution mutation; T790M mutation or other molecular abnormality will be allowed as long as it accompanies one of the mutations listed above; EGFR testing must be performed using a Food and Drug Administration (FDA)-approved test or in a Clinical Laboratory Improvement Amendments (CLIA)-certified laboratory. JAK2 exon 12 mutation: PV that lacks the JAK2V617F mutation but is characterized by the exon 12 mutation Pathologically confirmed diagnosis of non-small cell lung cancer with either EGFR exon 19 deletion mutation, EGFR exon 21 L858R point mutation, exon 18 G719X, and exon 21 L861Q; other rare EGFR mutations may be eligible after discussion with the overall principal investigator; mutations detected at outside laboratories are acceptable for enrollment NSCLC must harbor at least one of the following EGFR activating mutations: Exon 21 L858R, Exon 19 deletion, Exon 18 G719X, Exon 21 L861Q or for EGFR Exon 20 insertion expansion cohort D, NSCLC must harbor an EGFR Exon 20 insertion performed by a Clinical Laboratory Improvement Act (CLIA) certified test Dose escalation subjects: Epidermal Growth Factor Receptor (EGFR) activating mutation by local testing: exon 18 G719X, exon 19 deletion, exon 21 L861Q, exon 21 L858R or exon 20 insertion; and received prior treatment with EGFR Tyrosine Kinase Inhibitor (TKI) Subject on any line of treatment and has an EGFR exon 20 insertion mutation on examination of an NSCLC tissue or cellular specimen. Local testing may determine eligibility and a tumor sample should also be sent for central testing. Known EGFR exon 19 or 21 mutation or ALK rearrangement Subjects with characterized Epidermal Growth Factor Receptor (EGFR) activating mutations that predict sensitivity to anti-EGFR-therapy, including, but not limited to exon 19 deletions and exon 21 alterations At least one documented EGFR mutation which is known to be related with susceptibility to EGFR-TKIs (including G719X, exon 19 deletion, L858R, and L861Q) Subject has squamous NSCLC, or an untreated known EGFR mutation of exon 19 deletion or L858R mutation in exon 21, or a known ALK gene rearrangement. Subject has non-squamous NSCLC, or a known Epidermal Growth Factor Receptor (EGFR) mutation of exon 19 deletion or L858R mutation in exon 21, or a known Anaplastic Lymphoma Kinase (ALK) gene rearrangement. All adenocarcinoma patients will be tested for ALK rearrangements and EGFR (exon 19 deletion and exon 21 L8585R substitution) mutations and must have been treated with prior EGFR or ALK therapy as well as a platinum containing doublet Participants must have histologically or cytologically confirmed stage IV or recurrent non-small cell lung cancer with a documented exon 20 insertion mutation in EGFR (exon 20 insertion/deletion and deletion mutations will also be allowed) Confirmation that the tumour harbours an EGFR mutation known to be associated with EGFR TKI sensitivity (including G719X, exon 19 deletion, L858R, L861Q) OR Histologic documentation of primary lung carcinoma, non-squamous histology with activating epidermal growth factor receptor (defined as deletion 19 or exon 21 L858R mutation); Note: EGFR mutation testing must be performed at a Clinical Laboratory Improvement Amendments (CLIA) certified lab; either institutional or through a commercial laboratory (e.g. Genzyme, Response Genetics, etc); the laboratory report from the commercial laboratories report the specific mutations detected, and the method of detecting the exon 19 and exon 21 L858R point mutations must be available Evidence of either EGFR gene amplification by fluorescence in situ hybridization (FISH) or EGFR activating mutation in the most recent tumor specimen prior to enrollment; results of EGFR gene amplification will be confirmed by Dr. John Lafrate's laboratory at Massachusetts General Hospital (MGH) post hoc; gene amplification is defined as EGFR to Cen7 (centromere 7 copy number control) ratio of at least 2 to 1; for EGFR activating mutation, any one of the following EGFR mutations is eligible: extracellular domain mutation: EGFRvIII, R108K, T263P, A289V, A289D, A289T, G598V; or kinase domain mutation: G719X, T790M, exon19 deletions/insertions (at/near/within codons 744-759), exon 20 insertions/deletions/mutations (insertions/deletions at or near 766-769, S768I, R776C), L858R, L861Q Subject has an EGFR activating mutation (exon 19 deletion or exon 21 L858R), with or without T790M mutation, by local or central testing on examination of a NSCLC FFPE specimen (archival or fresh biopsy). Subjects harboring both exon 19 deletion and exon 21 L858R mutations are not eligible. A tissue sample from the same block used to determine eligibility by local testing should be available to send to the central lab for confirmatory testing. Subjects randomized based on local results indicating presence of EGFR mutation may remain on study if central results are discordant. Documented evidence of a tumor with activating EGFR mutations by local testing. Patients with exon 20 insertions are not eligible with the exception of patients with documented evidence of the exon 20 insertion A763_Y764insFQEA in the EGFR gene Documented evidence of an exon 20 insertion activating mutation other than A763_Y764insFQEA in the EGFR gene Subjects with known EGFR mutations which are sensitive to available targeted inhibitor therapy (including, but not limited to, deletions in exon 19 and exon 21 [L858R] substitution mutations) are excluded; all subjects with non-squamous histology must have been tested for EGFR mutation status; use of a Food and Drug Administration (FDA)-approved test is strongly encouraged Subject has a documented exon 19 deletion or exon 21 L858R EGFR activating mutation. Patients with tumors that harbor either EGFR sensitizing mutations or ALK rearrangement\r\n* EGFR sensitizing mutations include: \r\n** Exon 19 deletion or insertion\r\n** L858R (c.2573 T>G)\r\n** G719X (c.2156 G>C, G>T, or G>A)\r\n** L861Q (c.2582 T>A) Metastatic NSCLC with documented EGFR exon 19 deletion or exon 21 (L858R) substitution mutation If tumor histology is adenocarcinoma, must have wild-type EGFR genotype as assessed by a validated assay that includes exon 19 deletion and exon 21 (L858R) substitution. PHASE I: Patients must have metastatic/recurrent, histologically confirmed NSCLC that harbors an EGFR activating mutation (exon 21 L858R, exon 19 deletion, exon 18 G719X, exon 21 L861Q) with progressive disease by RECIST 1.1 on a previous EGFR-tyrosine kinase inhibitor (TKI); OR patients must have metastatic/recurrent histologically confirmed NSCLC that harbors an EGFR exon 20 insertion with progressive disease on platinum containing chemotherapy PHASE II COHORT A: Patients must have metastatic/recurrent histologically confirmed NSCLC that harbors an EGFR activating mutation (exon 21 L858R, exon 19 deletion, exon 18 G719X, exon 21 L861Q) with stable disease by RECIST 1.1 as best response on erlotinib compared to pre-treatment erlotinib imaging by RECIST 1.1 or progressive disease compared to pre-treatment imaging by RECIST 1.1 after a minimum duration of treatment on erlotinib of 12-weeks; patients must be enrolled within 6 months of initiation of erlotinib PHASE II COHORT B: Patients must have metastatic/recurrent histologically confirmed NSCLC that harbors an EGFR exon 20 insertion with progressive disease on or after platinum doublet chemotherapy Documented evidence in tumor of exon 20 insertion, small cell transformation, or MET amplification Patients with activating but not sensitizing mutations (exon 20 insertions, EGFR T790M) Activating EGFR mutation (exon 19 deletion, L858R, G719X, L861X) A documented somatic activating mutation in epidermal growth factor receptor (EGFR) (including but not limited to exon 19 deletion or L858R) For the MTD expansion cohort, patients will be eligible if they meet one of the following criteria:\r\n* Have an EGFR-sensitive mutation (as G719C in exon 18, E746-A750 in exon 90, L858R in exon 21) and have been previously treated with EGFR inhibitor therapy but have subsequently developed resistance, OR\r\n* Have an EGFR-resistant mutation (as T790M in exon 20), OR\r\n* Do not have an EGFR mutation, but have benefited from EGFR inhibitor therapy (including either >= 4 months of stable disease [SD] OR a >= partial response [PR]) Histologically or cytologically confirmed metastatic stage IIIB/IV lung adenocarcinoma with known activating mutations in the EGFR TK domain (including exon 19 deletion and L858R) NSCLC must harbor an EGFR activating mutation (Exon 21 L858R, Exon 19 deletion, Exon 18 G719X, Exon 21 L861Q) Histologically or cytologically documented metastatic or unresectable, locally advanced or metastatic NSCLC, with one or more activating EGFR mutation (eg, G719X, exon 19 deletion, L858R, L861Q) and absence of exon 20 insertion Historical confirmation that the tumor harbors an epidermal growth factor receptor (EGFR) mutation known to be associated with EGFR tyrosine kinase inhibitor (TKI) sensitivity (including G719X, exon 19 deletion, L858R, L861Q)