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

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

c = A("c")
m = B("m")
h = B("h")
g = A("g")
n = B("n")

c.u = h
m.o = h
m.z = h
h.o = m
h.z = m
g.u = n
n.o = h
n.z = m
assert h.o.o.o.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

c = A("c")
m = B("m")
h = B("h")
g = A("g")
n = B("n")

c.u = h
m.o = h
m.z = h
h.o = m
h.z = m
g.u = n
n.o = h
n.z = m
assert h.o.o.o.o.z.txt == "m"