def emulate_case(s: str, *, template: str) -> str:
    """Return the string s but emulating the case of the template
    (lower/upper/capitalized)"""
    if template.isupper():
        return s.upper()
    if template and template[0].isupper():
        return s.capitalize()
    return s