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

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

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

c = A("c")
d = B("d")
l = C("l")
i = A("i")
h = C("h")

c.t = d
c.q = d
d.p = l
l.p = d
l.w = h
i.t = d
i.q = d
h.p = d
h.w = l
assert c.t.p.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.q: B = None
        self.txt = txt

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

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

c = A("c")
d = B("d")
l = C("l")
i = A("i")
h = C("h")

c.t = d
c.q = d
d.p = l
l.p = d
l.w = h
i.t = d
i.q = d
h.p = d
h.w = l
assert c.t.p.w.w.txt == "l"