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

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

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

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

a.t = g
a.o = g
i.z = g
g.r = i
assert a.o.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.o: C = None
        self.txt = txt

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

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

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

a.t = g
a.o = g
i.z = g
g.r = i
assert a.o.r.z.txt == "g"