x = 0        # current value of sequence
a = 81       # multiplier
c = 337      # increment
m = 1000     # modulus

def rand():
    "Generate a random value"
    global x
    x = (a * x + c) % m
    return x

def reset(mult, inc, mod):
    "Define new a, c, and m values"
    global x, a, c, m
    x = 0
    a = mult
    c = inc
    m = mod
