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

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

b = A("b")
e = B("e")
h = A("h")

b.o = e
e.z = h
e.x = h
h.o = e
assert e.z.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

b = A("b")
e = B("e")
h = A("h")

b.o = e
e.z = h
e.x = h
h.o = e
assert e.z.o.z.txt == "h"