|Online Judge||Problem Set||Authors||Online Contests||User|
In the world of telecommunications phone calls to different phone numbers have to be charged using different rate or different billing plan. International Carrier of Phone Communications (ICPC) has an antique billing table that determines which phone call has to be charged using which billing plan.
Each international phone number has 11 digits. The billing table has n lines. Each line specifies a range of prefixes of phone numbers like “
ICPC’s billing table is old and contains many entries. Some of those entries may not be even used anymore. It is very hard to figure out which phone numbers each billing plan is actually used for. The ICPC’s management has reached a decision to transform this billing table into a more legible format. In this new format table consists of the lexicographically ordered list of simple prefixes (without the “
The first line of the input file contains a single integer number n (1 ≤ n ≤ 100) — the number of lines in the old billing table. The following n lines describe the old billing table with one rule on a line. Each rule contains four tokens separated by spaces — prefix A, minus sign (“
Further, let us denote with |A| the number of digits in the prefix A. It is true that 1 ≤ |B| ≤ |A| ≤ 11. Moreover, last |B| digits of prefix A form a string that is lexicographically equal or precedes B. Such pair of prefixes A and B matches all phone numbers with the first |A| − |B| digits matching the first digits of A and with the following |B| digits being lexicographically between the last |B| digits of A and B (inclusive).
Write to the output file a single integer number k — the minimal number of lines that the new table should contain to describe the given old billing table. Then write k lines with the lexicographically ordered new billing table. Write two tokens separated by a space on each line — the prefix and the billing plan name. Note, that the prefix in the new billing table shall contain at least one digit.
If all phone numbers are invalid (every phone number has no matching line or matches line with billing plan “
8 7919 - 921 cell 7921800 - 999 priv 1 - 1 usa 760 - 9 rsv 7928 - 29 rsv 7600 - 7899 spec 73 - 77 invalid 7 - 7 cis
35 1 usa 70 cis 71 cis 72 cis 76 rsv 77 spec 78 spec 790 cis 7910 cis 7911 cis 7912 cis 7913 cis 7914 cis 7915 cis 7916 cis 7917 cis 7918 cis 7919 cell 7920 cell 7921 cell 7922 cis 7923 cis 7924 cis 7925 cis 7926 cis 7927 cis 7928 rsv 7929 rsv 793 cis 794 cis 795 cis 796 cis 797 cis 798 cis 799 cis
[Submit] [Go Back] [Status] [Discuss]
Home Page Go Back To top
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator