import pymorphy3 _morph = pymorphy3.MorphAnalyzer() def make_word_agree_with_number(n: int, word: str) -> str: w = _morph.parse(word)[0] return w.make_agree_with_number(n).word