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

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

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

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

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

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

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

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

i.z = g
e.r = i
g.y = i
d.y = i
j.r = i
f.y = i
assert f.y.z.y.z.y.z.txt == "g"