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

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

e = A("e")
d = B("d")
b = A("b")
i = B("i")

e.s = b
e.r = b
d.o = e
b.s = e
b.r = e
i.o = e
assert i.o.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.r: A = None
        self.txt = txt

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

e = A("e")
d = B("d")
b = A("b")
i = B("i")

e.s = b
e.r = b
d.o = e
b.s = e
b.r = e
i.o = e
assert i.o.r.s.txt == "e"