There are some perfect squares with a particular property.
For example the number ```n = 256``` is a perfect square, its square root is ```16```. If we change the position of the digits of n, we may obtain another perfect square``` 625``` (square root = 25).
With these three digits ```2```,```5``` and ```6``` we can get two perfect squares: ```[256,625]```

The number ```1354896``` may generate another ```4``` perfect squares, having with the number itself, a total of five perfect squares: ```[1354896, 3594816, 3481956, 5391684, 6395841]```, being the last one in the list, ```6395841```, the highest value of the set.

Your task is to find the first perfect square above the given lower_limit, that can generate the given k number of perfect squares, and it doesn't contain the digit 0. Then return the maximum perfect square that can be obtained from its digits.

Example with the cases seen above:
```
lower_limit = 200
k = 2 (amount of perfect squares)
result = 625

lower_limit = 3550000
k = 5 (amount of perfect squares)
result  = 6395841
```
Features of the random tests:
```
100 <= lower_limit <= 1e6
2 <= k <= 5
number of tests = 45
```
Have a good time!

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

def _disabled_input(*args, **kwargs):
    raise RuntimeError("input() is disabled in callable mode")
builtins.input = _disabled_input

ns = {"__name__": "__judge__"}  # prevent if __name__ == "__main__" blocks
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'K_PERMS = {\n    2: [144, 256, 441, 625, 1369, 1764, 1936, 4761, 11236, 12769, 14884, 21316, 24649, 24964,\n        27556, 29584, 34596, 36864, 43264, 45369, 46656, 48841, 51984, 54289, 66564, 74529,\n        75625, 79524, 86436, 95481, 96721, 99856, 112225, 113569, 118336, 133956, 139876,\n        142884, 147456, 148225, 148996, 154449, 155236, 166464, 167281, 169744, 173889, 174724,\n        175561, 194481, 198916, 212521, 216225, 224676, 225625, 227529, 233289, 237169, 238144,\n        264196, 265225, 267289, 272484, 287296, 293764, 314721, 316969, 323761, 328329, 329476,\n        344569, 345744, 355216, 368449, 369664, 374544, 383161, 391876, 398161, 427716, 432964,\n        434281, 447561, 456976, 459684, 463761, 467856, 474721, 498436, 521284, 522729, 546121,\n        591361, 594441, 611524, 619369, 622521, 627264, 646416, 649636, 654481, 659344, 667489,\n        669124, 675684, 678976, 712336, 729316, 736164, 741321, 748225, 755161, 758641, 769129,\n        772641, 779689, 781456, 786769, 793881, 795664, 799236, 817216, 835396, 842724, 844561,\n        848241, 874225, 877969, 891136, 894916, 919681, 927369, 933156, 948676, 956484, 964324,\n        972196, 976144, 9114361],\n    3: [961, 9216, 11664, 12544, 16641, 18225, 23716, 25281, 32761, 41616, 42849, 44521, 49284,\n        52441, 72361, 81225, 82944, 131769, 141376, 149769, 164836, 165649, 197136, 319225,\n        349281, 364816, 378225, 381924, 417316, 471969, 481636, 541696, 837225, 931225, 974169,\n        7112889],\n    4: [81796, 112896, 132496, 168921, 195364, 214369, 269361, 298116, 346921, 395641, 436921,\n        543169, 962361, 4511376],\n    5: [43681, 6395841],\n    6: [7241481],\n    7: [4532641] }\n\n\ndef next_perfectsq_perm(lower_limit, k, answer = 0):\n    \n    for number in K_PERMS[k]:\n        if not answer and number > lower_limit:\n            answer = number\n        elif answer and sorted(str(number)) == sorted(str(answer)):\n            answer = number\n    \n    return answer'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

_target = None
_fn_name = 'next_perfectsq_perm'
if _fn_name:
    if "Solution" in ns:
        try:
            _obj = ns["Solution"]()
            if hasattr(_obj, _fn_name):
                _target = getattr(_obj, _fn_name)
        except Exception:
            _target = None
    if _target is None and _fn_name in ns and callable(ns[_fn_name]):
        _target = ns[_fn_name]
# Fallback: if there's exactly one user-defined function, use it
if _target is None:
    _cands = [v for k, v in ns.items() if callable(v) and getattr(v, "__module__", "") in ("__judge__", "__main__")]
    _user_funcs = [c for c in _cands if getattr(c, "__name__", "").startswith("_") is False]
    if len(_user_funcs) == 1:
        _target = _user_funcs[0]
if _target is None:
    raise RuntimeError(f"Could not resolve callable '{_fn_name}'")

_raw = sys.stdin.read().strip()
if _raw:
    _parsed = json.loads(_raw)
    if isinstance(_parsed, dict):
        _kwargs = _parsed.get("kwargs", {})
        _args = _parsed.get("args", [])
    else:
        _args, _kwargs = _parsed, {}
else:
    _args, _kwargs = [], {}
if not isinstance(_args, (list, tuple)):
    _args = [_args]
_res = _target(*_args, **_kwargs)
try:
    sys.stdout.write(repr(_res) + "\n")
except Exception:
    pass

```

Measured memory_bytes: 5532