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

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

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

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

f.x = d
f.y = i
g.t = f
g.r = i
g.u = d
d.u = i
d.z = i
i.u = d
i.z = d
assert i.u.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: C = None
        self.txt = txt

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

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

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

f.x = d
f.y = i
g.t = f
g.r = i
g.u = d
d.u = i
d.z = i
i.u = d
i.z = d
assert i.u.u.z.txt == "d"