class Point:
    def __init__(P, x, y, p):
        P.x = x
        P.y = y
        P.p = p

    def __add__(P, Q):
        return P.__radd__(Q)

    def __mul__(P, x):
        return P.__rmul__(x)

    def __sub__(P, x):
        return P.__rsub__(x)

    def __rmul__(P, x):
        n = P
        q = None

        for i in range(256):
            if x & (1 << i):
                q = q + n
            n = n + n

        return q

    def __radd__(P, Q):
        if Q is None:
            return P

        if P == Q:
            d = 2 * P.x
            s = pow(2 * P.y % P.p, P.p-2, P.p) * (3 * P.x ** 2) % P.p
        else:
            d = P.x + Q.x
            s = pow(Q.x - P.x, P.p-2, P.p) * (Q.y - P.y) % P.p

        x = (s ** 2 - d) % P.p
        y = (s * (P.x - x) - P.y) % P.p
        return Point(x, y, P.p)

    def __neg__(P):
        return Point(P.x, -P.y, P.p)

    def __rsub__(P, Q):
        return P + -Q

    def __str__(P):
        return "x: %064x y: %064x" % (P.x, P.y)

SPEC256k1 = Point(
    x = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798,
    y = 0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8,
    p = 2**256 - 2**32 - 977
)