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

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

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

e.o = h
e.q = h
d.s = e
h.s = e
assert h.s.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: B = None
        self.txt = txt

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

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

e.o = h
e.q = h
d.s = e
h.s = e
assert h.s.q.s.txt == "e"