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

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

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

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

e.p = i
e.w = b
b.x = e
i.z = e
i.q = b
assert e.w.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: B = None
        self.txt = txt

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

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

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

e.p = i
e.w = b
b.x = e
i.z = e
i.q = b
assert e.w.x.p.txt == "i"