+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
The **International Mobile Equipment Identity** or **IMEI** /aɪˈmiː/ is a number, usually unique, to identify 3GPP and iDEN mobile phones, as well as some satellite phones. It is usually found printed inside the battery compartment of the phone, but can also be displayed on-screen on most phones by entering *#06# on the dialpad, or alongside other system information in the settings menu on smartphone operating systems.
![توضیح تصویر](https://quera.org/qbox/view/tV9q1q1psq/G_1.png)
The IMEI number is used by a GSM network to identify valid devices and therefore can be used for stopping a stolen phone from accessing that network. For example, if a mobile phone is stolen, the owner can call their network provider and instruct them to blacklist the phone using its IMEI number. This renders the phone useless on that network and sometimes other networks too, whether or not the phone's subscriber identity module (SIM) is changed.
The IMEI is only used for identifying the device and has no permanent or semi-permanent relation to the subscriber. Instead, the subscriber is identified by transmission of an International mobile subscriber identity (IMSI) number, which is stored on a SIM card that can in theory be transferred to any handset. However, many network and security features are enabled by knowing the current device being used by a subscriber.
The IMEI (15 decimal digits: 14 digits plus a check digit) includes information on the origin, model, and serial number of the device. The model and origin comprise the initial 8-digit portion of the IMEI, known as the Type Allocation Code (TAC). The remainder of the IMEI is manufacturer-defined, with a Luhn check digit at the end.
![توضیح تصویر](https://quera.org/qbox/view/loaC5fe6be/G_2.png)
New style IMEI code 49-015420-323751 has an 8-digit TAC of 49-015420.
The last number of the IMEI is a check digit calculated using the Luhn algorithm, as defined in the IMEI Allocation and Approval Guidelines:
+ The Check Digit shall be calculated according to Luhn formula. The Check Digit is a function of all other digits in the IMEI.
+ The purpose of the Check Digit is to help guard against the possibility of incorrect entries to the CEIR and EIR equipment.
+ The presentation of the Check Digit both electronically and in printed form on the label and packaging is very important. Logistics (using bar-code reader) and EIR/CEIR administration cannot use the Check Digit unless it is printed outside of the packaging, and on the ME IMEI/Type Accreditation label.
+ The check digit is not transmitted over the radio interface, nor is it stored in the EIR database at any point. Therefore, all references to the last three or six digits of an IMEI refer to the actual IMEI number, to which the check digit does not belong.
The check digit (Checksum or Luhn Checksum) is validated in three steps:
1. Starting from the right, double every other digit (e.g., 7 → 14).
2. Sum the digits (e.g., 14 → 1 + 4).
3. Check if the sum is divisible by 10.
Conversely, one can calculate the IMEI by choosing the check digit that would give a sum divisible by 10. For the example IMEI 49015420323751? ,
![توضیح تصویر](https://quera.org/qbox/view/tCk9YGtMtt/G_3.png)
To make the sum divisible by 10, we set x = 8, so the complete IMEI become 490154203237518. Your task is simple, given a 14 digit IMEI, calculate its TAC and its check digit.
# ورودی
The first line of input indicates the number of test cases (There will be at most 20 test cases)
For each test case, there is a 14-digit IMEI in a single line.
# خروجی
For each test case, print TAC and Checksum of given IMEI respectively in a single line.
# مثالها
## ورودی نمونه ۱
```
2
49015420323751
01234567890123
```
## خروجی نمونه ۱
```
49015420 8
01234567 7
```
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.