Panini football stickers are pure nostalgia! They are produced by the Italian-based Panini company that is specialized in the distribution of self-adhesive sticker collections. Ever since its foundation, the company produces sticker collections about movies and computer games, but the football collections have always been by far the most popular ones.

Mexico 86
Panini football stickers of some of the player of the Red Devils, the Belgian football team that participated in the 1986 World Cup soccer in Mexico.

Every Panini booklet contains hundreds of empty placeholders that need to be covered by different stickers. The stickers are numbered sequentially so that their position in the booklet can be found easily. Four or five randomly selected stickers are bundled together in a sealed container. This way, collectors do not know in advance which stickers they purchase. As a result, it becomes extremely hard to complete the entire collection, creating a collective rage whereby collectors mutually exchange their duplicate stickers.

Because collectors need to be able to quickly lookup what stickers that already have in their possession while exchanging stickers, they use a shorthand notation to describe their collection. Say, for example, that a collector has the following stickers in his possession

1, 3, 4, 5, 6, 7, 9, 10, 11, 17, 19, 20

then he will describe his collection using the following shorthand notation.

1, 3-7, 9-11, 17, 19-20

This notation abbreviates each sequence of successive integers as the first and the last integer in the sequence, separated from each other using a dash (-). Individual integers and integer sequences are listed in increasing order, separated from each other using a comma (,) and a space.

Assignment

Define a class Panini that can be used to represent collections of Panini stickers. Each sticker occurs at most once in the collection. The class must support at least the following methods:

In addition, it should also be possible to use the built-in functions repr and str to generate a string representation for each object of the class Panini. The string returned by these functions must contain the shorthand notation of the collection of stickers represented by the object. Both function should thus return the same string representation of an object.

Example

>>> collection1 = Panini([1, 3, 4, 5, 6, 7, 9, 10, 11, 17, 19, 20])
>>> collection1
1, 3-7, 9-11, 17, 19-20
>>> print(collection1)
1, 3-7, 9-11, 17, 19-20

>>> collection2 = Panini(8)
>>> collection2
8
>>> print(collection2)
8

>>> collection3 = collection1 + collection2
>>> isinstance(collection3, Panini)
True
>>> collection3
1, 3-11, 17, 19-20

>>> collection4 = collection1 - Panini((5, 8))
>>> isinstance(collection4, Panini)
True
>>> collection4
1, 3-4, 6-7, 9-11, 17, 19-20

>>> collection1 - Panini({1, 2, 3, 4}) + Panini(list(range(10, 19)))
5-7, 9-20

>>> Panini('spam')
Traceback (most recent call last):
AssertionError: invalid stickers
>>> Panini([1, 2, 3.14])
Traceback (most recent call last):
AssertionError: invalid stickers