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

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

e = A("e")
a = B("a")
f = B("f")

e.p = a
e.o = f
a.w = f
f.w = a
assert e.p.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: B = None
        self.txt = txt

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

e = A("e")
a = B("a")
f = B("f")

e.p = a
e.o = f
a.w = f
f.w = a
assert e.p.w.w.txt == "a"