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

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

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

m = A("m")
g = B("g")
e = C("e")
i = B("i")
f = C("f")

m.s = g
m.q = g
g.t = e
e.u = i
i.t = f
f.u = i
assert f.u.t.u.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.q: B = None
        self.txt = txt

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

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

m = A("m")
g = B("g")
e = C("e")
i = B("i")
f = C("f")

m.s = g
m.q = g
g.t = e
e.u = i
i.t = f
f.u = i
assert f.u.t.u.t.u.txt == "i"