def subvals(x, ivs):
    """Replace the i-th value of x with v.

    Args:
      x: iterable of items.
      ivs: list of (int, value) pairs.

    Returns:
      x modified appropriately.
    """
    x_ = list(x)
    for i, v in ivs:
        x_[i] = v
    return tuple(x_)