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

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

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

h = A("h")
m = B("m")
d = C("d")
e = B("e")
l = C("l")

h.t = d
m.v = l
d.w = h
d.q = m
d.t = m
e.v = l
l.w = h
l.q = e
l.t = m
assert h.t.t.v.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

h = A("h")
m = B("m")
d = C("d")
e = B("e")
l = C("l")

h.t = d
m.v = l
d.w = h
d.q = m
d.t = m
e.v = l
l.w = h
l.q = e
l.t = m
assert h.t.t.v.q.v.txt == "l"