Diaa does SMS

Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 256M

Problem types

We all know Diaa as a MACS member, but very few people know that his initial professional profile is as a telecom engineer. Diaa had a critical task in the past to generate a complete list of verbose information about a set of problematic subscribers on the SMS solution.

As lazy as he is, he asked 2 of his colleagues to give him the data, unfortunately, none of the provided data was complete, one set of data contains only the MSIDN and the IMSI , and the other contains only the IMSI and the region.

Your task is to generate one list of the 3 pieces of data correctly mapped.

Input Specification

The first line of the input contains an integer \(0 \leq N \leq 100\) indicating the total number of lines in the first list.

Followed by a \(N\) lines, each line contains 2 Strings separated by a comma: MSISDN,IMSI

MSISDN is a String starting with '+' and followed by \(12\) digits.

IMSI is a String composed of \(14\) digits.

After this list you will find a line containing one integer \(1 \leq M \leq 100\), indicating the total number of lines of the second list, followed by M lines.

Each line is composed of \(2\) Strings separated by a comma: Region,MSISDN

Region is a String composed of Alphabet characters, and MSISDN has the same form as in the first list.

Output Specification

For each MSISDN print one line with the 3 information:


Sorted Alphabetically by MSIDN then IMSI and by region.

Sample Input


Sample Output



If you cannot find a correct mapping for a MSISDN, you should ignore it from the final output.

If no mappings could be found print \("no match"\) without quotes.


  • 0
    moutafaddilnajib  commented on May 15, 2023, 5:03 p.m.

    I used while in the input that his length is supposed to be 12 , but I still have WA in the second case.

    • 0
      YassirSalama  commented on May 17, 2023, 3:12 p.m.

      There was a problem on test cases, The input length is not always 12 so, so split using the ,

  • 0
    Benelakir  commented on May 10, 2023, 3:21 p.m.

    Oh yeh that is the reason, thank you a lot AkramElOmrani

  • 0
    Benelakir  commented on May 2, 2023, 6:57 p.m.

    can someone say to me why my code gives me WA in the second case. please.