def isAutomorphic(N):
# Store the square
if N < 0:
N = -N
sq = N * N
# Start Comparing digits
while (N > 0) :
# Return false, if any digit of N doesn't
# match with its square's digits from last
if (N % 10 != sq % 10) :
return False
# Reduce N and square
N //= 10
sq //= 10
return True
# Driver code
N = 5
if isAutomorphic(N) :
print ("Automorphic")
else :
print ("Not Automorphic")
ZGVmIGlzQXV0b21vcnBoaWMoTik6CgoJIyBTdG9yZSB0aGUgc3F1YXJlCglpZiBOIDwgMDoKCQlOID0gLU4KCXNxID0gTiAqIE4KCQoJIyBTdGFydCBDb21wYXJpbmcgZGlnaXRzCgl3aGlsZSAoTiA+IDApIDoKCgkJIyBSZXR1cm4gZmFsc2UsIGlmIGFueSBkaWdpdCBvZiBOIGRvZXNuJ3QKCQkjIG1hdGNoIHdpdGggaXRzIHNxdWFyZSdzIGRpZ2l0cyBmcm9tIGxhc3QKCQlpZiAoTiAlIDEwICE9IHNxICUgMTApIDoKCQkJcmV0dXJuIEZhbHNlCgoJCSMgUmVkdWNlIE4gYW5kIHNxdWFyZQoJCU4gLy89IDEwCgkJc3EgLy89IDEwCgoJcmV0dXJuIFRydWUKCiMgRHJpdmVyIGNvZGUKTiA9IDUKaWYgaXNBdXRvbW9ycGhpYyhOKSA6CglwcmludCAoIkF1dG9tb3JwaGljIikKZWxzZSA6CglwcmludCAoIk5vdCBBdXRvbW9ycGhpYyIpCg==