
ZOJ Problem Set  3300
Mahjong is a favorite pastime in China. It can be played either with a set of mahjong tiles or a set of mahjong playing cards (sometimes spelled "kards" to distinguish them from the list of standard hands used in American mahjong). One brand of mahjong cards calls these Mhing. Playing cards are often used when travelling, as they take up less space and are lighter than their tile counterparts;however, they are usually of a lower quality. In this article, "tile" will be used to denote both playing cards and tiles. There are many variations of mahjong. In many places, players often observe one version and are either unaware of other variations or claim that different versions are incorrect. Here, we are using the 13tile version. In order to simplify the problem. We only consider 13 tiles of Suit Character (named as each tile represents ten thousand coins, or one hundred strings of one hundred coins): We use a single integer (1 to 9) to represent a tile (Character 1 to 9) in this problem. In this simplified problem, consider below melds only(refer to Mahjong  Wikipedia for complete description):
A player wins by creating a standard mahjong hand, which consists of a certain number of melds (four for 13tile version) and a single Eye. Your task is to figure out which tile can make you win according to 13 tiles you already have. Note that you can't have more than 4 tiles with a same number at any time. Input Multi cases (no more than 25). Process to the end. Each case has a single line containing 13 integers, which are tiles you already have. Output For each case, output tiles that can make you win in one line(sorted, smaller first), separated by one space. There is always a solution. Sample Input 1 3 4 4 4 4 5 6 6 7 7 7 8 Sample Output 2 Author: WU, Jun Source: ZOJ Monthly, February 2010 