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

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

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

f = A("f")
d = B("d")
i = C("i")

f.o = i
f.s = d
d.u = i
d.q = i
i.y = f
i.s = d
i.z = d
assert d.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: B = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
i = C("i")

f.o = i
f.s = d
d.u = i
d.q = i
i.y = f
i.s = d
i.z = d
assert d.q.s.q.txt == "i"