from typing import Tuple
import re


def parse_bagexpr(text: str) -> Tuple[int, str]:
    """
    Parse the expression representing a bag.

    :return: number of units, kind
    """
    match = re.fullmatch(r"(\d+) (.*) bags?", text)
    assert match
    num, kind = match.groups()
    return int(num), kind