def METHOD_NAME(x, p):
    if x==0:
        return True
    # Check parity of valuation
    v=valuation(x,p)
    if v%2:
        return False
    # Renormalise to get a unit
    x//=p**v
    # Reduce mod p and conclude
    if p==2:
        return Mod(x,8)==1
    else:
        return kronecker_symbol(x,p)==1