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

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

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

m = A("m")
i = B("i")
f = C("f")
a = C("a")
d = C("d")
j = A("j")

m.z = j
m.y = i
i.r = d
f.t = i
f.v = i
f.r = i
a.t = i
a.v = i
a.r = i
d.t = i
d.v = i
d.r = i
j.z = m
j.y = i
assert d.r.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.y: B = None
        self.txt = txt

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

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

m = A("m")
i = B("i")
f = C("f")
a = C("a")
d = C("d")
j = A("j")

m.z = j
m.y = i
i.r = d
f.t = i
f.v = i
f.r = i
a.t = i
a.v = i
a.r = i
d.t = i
d.v = i
d.r = i
j.z = m
j.y = i
assert d.r.r.t.txt == "i"