Step 1: Identify the reagent and its behaviour.
The sequence uses potassium cyanide, KCN, reacting with an alkyl halide. The cyanide ion is ambidentate, meaning it can attach through either its carbon or its nitrogen end.
Step 2: Recall the preference with alkyl halides.
With KCN (an ionic cyanide) and an alkyl halide in an SN2 reaction, the more nucleophilic carbon end attacks. This makes an alkyl nitrile, $R-CN$, not the isocyanide.
Step 3: Form the first product X.
So the alkyl halide reacts as $R-X + KCN \rightarrow R-CN$, meaning X contains the nitrile group, that is $-CN$.
Step 4: Form the second product Y.
The second substitution again uses KCN with the same carbon end preference, so Y is likewise a nitrile, $-CN$.
Step 5: Note the bonding in both products.
Both X and Y contain the $C \equiv N$ triple bond joined through carbon, the hallmark of nitriles.
Step 6: Conclude.
Therefore X and Y are both $CN$ (nitriles).
\[ \boxed{CN, CN} \]