Lucky Digits and Modulo
Tag(s):

## Easy, Lucky-Digit, Math, Simple-math

Problem
Editorial
Analytics

Given a number N find out the minimum number M such that result of N modulo M become either 4 or 7.

Input:
First line of input contains number of test cases T. Each test case contains a single integer N.

Output:
Print the minimum value of M such that result of N%M become either 4 or 7 if there is no any value of M exists then print -1.

Constraints:
1 <= T <= 103
1 <= N <= 109

SAMPLE INPUT
2
9
10
SAMPLE OUTPUT
5
6
Explanation
Test Case #1:
For N=9, minimum value of M will be 5.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

Honeywell iOS Hiring Challenge

OTHER PROBLEMS OF THIS CHALLENGE
• Algorithms > Sorting