This page is still under construction.

Parts of this page are still being built. What you see may change.

Snow Calls

Interview

Time limit1sMemory limit128 MB

Summary
Convert each alphanumeric phone number to digits, keep the first 10 digits, and print them in xxx-xxx-xxxx form.
Level

Easy2 of 10

Topics
String, Implementation, Hash map
Solved
No attempts yet

Problem

You have been snowed in at your summer home, and without the Internet! That means the phone is your only way to get what you need to survive: pizza, pop, and the latest video games.

Companies often replace the digits in their phone numbers with letters to make them more memorable. After all, 416-BUY-MORE is easier to remember than 416-289-6673. Some numbers even carry extra letters or digits (such as 604-PIZZABOX), but any digit beyond the 10th is irrelevant.

Doing the conversion by hand is tedious, so write a program that rewrites every phone number in your phone book into the form xxx-xxx-xxxx. Use the telephone keypad below to turn each letter into a digit, copy digits unchanged, ignore the hyphens, and keep only the first 10 digits.

DigitLetters
2A B C
3D E F
4G H I
5J K L
6M N O
7P Q R S
8T U V
9W X Y Z

Input

The first line contains an integer tt, the number of test cases. Each of the following tt lines contains one valid phone number made of alphanumeric characters separated by hyphens. No line is longer than 40 characters.

Output

For each test case, print the phone number in the form xxx-xxx-xxxx on its own line.

Examples1

  1. Example 1

    Input
    5
    88-SNOW-5555
    519-888-4567
    BUY-MORE-POP
    416-PIZZA-BOX
    5059381123
    
    Expected output
    887-669-5555
    519-888-4567
    289-667-3767
    416-749-9226
    505-938-1123