Every number whose unit’s digit is 3 has a repunit as its multiple. A repunit is a number which has only ones. It is of the form (10^{n} – 1)/9. Example: 3 divides 111, 13 divides 111111.

A positive integer N will be given whose unit’s digit is 3. The task is to find the number of 1s in the smallest repunit which is divisible by the given number N.

**Input: **

The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of a single line containing a positive integer N whose unit’s digit is 3.

**Output:**

Corresponding to each test case, in a new line, print the number of 1s in the smallest repunit multiple of the number.

**Constraints:**

1 ≤ T ≤ 100

1 ≤ N ≤ 10^{7}

**Example:**

**Input:**

2

3

23

**Output:**

3

22

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

mantan_g | 267 |

tushki | 198 |

aksht7 | 182 |

ayush1101 | 128 |

namansharmacse17 | 110 |

ARUN_PUNDIR | 730 |

manishgupta8497 | 627 |

AMAN__JAIN | 625 |

Abhimanyu_kumar | 562 |

AJ786 | 541 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4584 |

Login to report an issue on this page.