An Adaptive Network That Learns Sequences of Transitions