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.v: B = None
        self.txt = txt

h = A("h")
c = B("c")
a = B("a")

h.z = a
c.u = a
c.v = a
a.u = c
a.v = c
assert c.v.v.v.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.v: B = None
        self.txt = txt

h = A("h")
c = B("c")
a = B("a")

h.z = a
c.u = a
c.v = a
a.u = c
a.v = c
assert c.v.v.v.txt == "a"