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

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

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

m = A("m")
d = B("d")
i = C("i")
l = B("l")
a = A("a")
b = C("b")

m.t = d
m.p = l
d.s = l
i.t = l
i.q = b
l.s = d
a.t = l
a.p = d
b.t = l
b.q = i
assert a.p.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: B = None
        self.txt = txt

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

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

m = A("m")
d = B("d")
i = C("i")
l = B("l")
a = A("a")
b = C("b")

m.t = d
m.p = l
d.s = l
i.t = l
i.q = b
l.s = d
a.t = l
a.p = d
b.t = l
b.q = i
assert a.p.s.s.txt == "d"