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

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

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

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

a.t = i
a.p = m
i.o = m
i.u = d
d.s = i
g.t = i
g.p = m
m.s = i
assert d.s.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: C = None
        self.txt = txt

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

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

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

a.t = i
a.p = m
i.o = m
i.u = d
d.s = i
g.t = i
g.p = m
m.s = i
assert d.s.o.s.txt == "i"