Inclusion Criteria:  Patients have measurable disease per Response Evaluation Criteria in Solid Tumors version 1.1 (RECIST v1.1). Patients must have disease with evidence of KRAS G12C mutation in tumor tissue or circulating tumor deoxyribonucleic acid (DNA). Participants must have a histological or a cytologically proven diagnosis of locally advanced, unresectable, and/or metastatic cancer and meet cohort-specific criteria. Have an Eastern Cooperative Oncology Group (ECOG) Performance Status of 0 or 1. Have adequate organ function. Have discontinued all previous treatments for cancer with resolution of any significant ongoing adverse events (AEs). Must be able to swallow capsule/tablet. Agree and adhere to contraceptive use, if applicable.  Exclusion Criteria:  Disease suitable for local therapy administered with curative intent. Have an active, ongoing, or untreated infection. Have a serious pre-existing medical condition(s) that, in the judgment of the investigator, would preclude participation in this study. Have a serious cardiac condition. Have a second active primary malignancy or have been diagnosed and/or treated for an additional malignancy within 3 years prior to enrollment. Have symptomatic central nervous system (CNS) malignancy or metastasis and/or carcinomatous meningitis. Patients with treated CNS metastases are eligible for this study if they are not currently receiving corticosteroids in excess of 10 milligrams (mg) per day prednisone/prednisolone (or equivalent) and their disease is asymptomatic and radiographically stable for at least 30 days. Have received prior treatment with any KRAS G12C small molecule inhibitor, except in certain scenarios where such prior therapy is allowed as per protocol. For Cohorts B2, B3, and B5/C1, patients treated with drugs known to be strong inhibitors or inducers of cytochrome P450 (CYP)3A.  The following patients will be excluded from Cohort B4:  Experienced certain serious side effects with prior immunotherapy. Have an active autoimmune disease that has required systemic anti-autoimmune treatment in the past 2 years. Have undergone prior allogeneic hematopoietic stem cell transplantation within the last 5 years. Have received a live vaccine within 30 days prior to the first dose of study drug. Pregnant, breastfeeding, or expecting to conceive or father children within the projected duration of the trial through 180 days after the last dose of study medication. Known allergic reaction against any of the components of the study treatments.