Activation Key Regrouping

An OEM partner ships devices whose activation keys were stamped onto the label by an engraving head. The stamping process is sloppy: dash separators land at arbitrary positions, runs of dashes sometimes appear back to back, and letters may come out lowercase depending on which head did the engraving.

Before an installer can activate a device, the raw stamp must be normalized into a display key using these rules:

  1. Remove every dash from the raw stamp.
  2. Convert all remaining letters to uppercase. Digits stay as they are.
  3. Regroup the cleaned characters so that every group contains exactly k characters, except the first group, which holds whatever is left over when the cleaned length is not a multiple of k. Whenever at least one character survives cleaning, the first group must be non-empty.
  4. Join the groups with single dashes and return the result.

If the raw stamp contains no letters or digits at all, return the empty string.

Examples
Input: ["ab-cd-efg",3]
Output: "A-BCD-EFG"
Hints

Activation Key Regrouping

An OEM partner ships devices whose activation keys were stamped onto the label by an engraving head. The stamping process is sloppy: dash separators land at arbitrary positions, runs of dashes sometimes appear back to back, and letters may come out lowercase depending on which head did the engraving.