The leaders of Russia have been alternately bald and hairy since 1881.
And monarchs' profiles on British coins have faced alternately left and right since 1653. The exception is Edward VIII, who stares obstinately at the back of George V's head.
For a given sequence of items, determine if they have alternating values for one of their properties. For non-alternating sequences we also want to check if there is a single exception that would make the sequence alternating if it would have another value for the property.
A sequence of two or more items. Each item is described on a separate line by its name, a tab and its value for a particular property of the items. We guarantee that the first two items have different values for this property. The sequence ends with a line containing the word stop.
In case all items in the sequence have alternating values for the property, the output should contain the text alternating sequence. Otherwise the output should contain the text no alternating sequence, unless there is one exception that would make the sequence alternating if it would have another value for the property. In the latter case, the output should contain the text alternating sequence with one exception: name, where name must be filled up with the name of the exceptional item.
Input:
Alexander III bald
Nicholas II hairy
Vladimir Lenin bald
Joseph Stalin hairy
Nikita Khrushchev bald
Leonid Brezhnev hairy
Yuri Andropov bald
Konstantin Chernenko hairy
Mikhail Gorbachev bald
Boris Yeltsin hairy
Vladimir Putin bald
Dmitry Medvedev hairy
Vladimir Putin bald
stop
Output:
alternating sequence
Input:
Oliver Cromwell left
Charles II right
James II left
William & Mary right
Anne left
George I right
George II left
George III right
George IV left
William IV right
Victoria left
Edward VII right
George V left
Edward VIII left
George VI left
Elizabeth II right
stop
Output:
alternating sequence with one exception: Edward VIII
Input:
January 31
February 29
March 31
April 30
May 31
June 30
July 31
August 31
September 30
October 31
November 30
December 31
stop
Output:
no alternating sequence