add and mul to 0 and 1, respectively.append(val) is called, adjust val by subtracting add and then multiplying by the modular inverse of mul, and append it to the sequence.addAll(inc) is called, increment add by inc.multAll(m) is called, multiply mul and add by m.getIndex(idx) is called, if idx is out of bounds, return -1. Otherwise, return the value at idx after applying the mul and add operations.