class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.v: B = None
        self.txt = txt

c = A("c")
h = B("h")
i = C("i")
n = B("n")
k = B("k")

c.z = k
h.u = k
i.p = c
i.v = n
n.u = h
k.u = h
assert c.z.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.v: B = None
        self.txt = txt

c = A("c")
h = B("h")
i = C("i")
n = B("n")
k = B("k")

c.z = k
h.u = k
i.p = c
i.v = n
n.u = h
k.u = h
assert c.z.u.u.txt == "k"