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

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

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

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

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

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

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

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

i.u = f
i.s = a
g.z = a
f.y = g
a.z = g
assert f.y.z.z.txt == "g"