All squares that match a wildcard sequence This was inspired by part of the 2016 ARML competition Team Problem #6.

Here's the challenge:

You're given a "wildcard sequence", which is a sequence of digits and another character. A string matches this wildcard sequence by the following pseudocode:

w = wildcard
s = string
# s matches w iff
for all 0 &gt;= i &gt; wildcard.length, w[i] == '?' or s[i] == w[i]


Where '?' is a character of your choice.

In terms of regex, just imagine the '?' to be '.'.

The challenge is to find all square numbers (the requirement is up to 1 million) whose decimal string representations match this wildcard sequence. The "wildcard character" can be any ASCII character of your choice, as long as it isn't a digit, obviously.

For example, 4096 matches 4**6 and 4*9* but 4114 does not match either.

Input

Input will be given as a sequence matching the regex [0-9?]+. This can be a string, a character array, or a byte array of the characters in ASCII.

Output

Output will be a whatever-you-want-delimited list/set/array of numbers which are perfect squares and match the wildcard sequence.

Examples of valid inputs:

1234567*90
1234567?90
1234567u90
['1', '2', '3', '4', '5', '6', '7', '*', '9', '0']
[49, 50, 51, 52, 53, 54, 55, 42, 57, 48]
[1, 2, 3, 4, 5, 6, 7, '*', 9, 0]


Examples of valid outputs:

[1, 4, 9]
1 4 9
1, 4, 9
1-4-9


etc.

Specifications


You may not use builtins for finding a list of squares in a certain range
Standard Loopholes Apply
You must be able to handle up to 1 000 000 (1 million)
If provided with the input 1******, it is correct to print [1000000]. It is also correct to print [1000000, 1002001, 1004004, 1006009, 1008016, 1010025, ...]
Wildcard sequences will never start with the wildcard character; that is, they will always match strings of the same length.


Test Cases

4**6  -&gt;  [4096, 4356]
1**1  -&gt;  [1521, 1681]
1**  -&gt;  [100, 121, 144, 169, 196]
9****9  -&gt;  [908209, 915849, 927369, 935089, 946729, 954529, 966289, 974169, 986049, 994009]
9*9***  -&gt;  [919681, 929296]
1**0*  -&gt;  [10000, 10201, 10404, 10609, 12100, 14400, 16900, 19600]
9***4  -&gt;  [91204, 94864, 97344]


Winning

Shortest (valid) (working) submission by February 14th, tie-break by earliest submission winning.
Mathematica, 44 bytes
Print@@@IntegerDigits[Range@1*^3^2]~Cases~#&amp;

The input is a list of digits with a _ (no quotes) as a wildcard. e.g. {4, _, _, 6}
Explanation
Range@1*^3

Generate list {1, 2, 3, ... , 1000}
... ^2

Square it. (list of all squares from 1 to 1,000,000)
IntegerDigits[ ... ]

Split each square into a list of digits.
... ~Cases~#

Find the ones that match the pattern specified by the input.
Print@@@ ...

Print them.