<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def trainSequences(sequences, exp, idOffset=0):
 """Train the network on all the sequences"""

  for seqId in sequences:
    # Make sure we learn enough times to deal with high order sequences and
    # remove extra predictions.
    iterations = 3*len(sequences[seqId])
    for p in range(iterations):

      # Ensure we generate new random location for each sequence presentation
      s = sequences.provideObjectsToLearn([seqId])
      objectSDRs = dict()
      objectSDRs[seqId + idOffset] = s[seqId]
      exp.learnObjects(objectSDRs, reset=False)

      # TM needs reset between sequences, but not other regions
      exp.TMColumns[0].reset()

    # L2 needs resets when we switch to new object
    exp.sendReset()