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

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

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

c = A("c")
e = B("e")
i = C("i")
f = C("f")

c.q = i
c.y = i
e.u = f
e.w = c
i.w = c
i.z = e
i.x = f
f.w = c
f.z = e
f.x = i
assert c.y.w.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: C = None
        self.txt = txt

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

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

c = A("c")
e = B("e")
i = C("i")
f = C("f")

c.q = i
c.y = i
e.u = f
e.w = c
i.w = c
i.z = e
i.x = f
f.w = c
f.z = e
f.x = i
assert c.y.w.y.x.txt == "f"