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

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

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

e = A("e")
k = B("k")
c = C("c")
m = C("m")
d = C("d")

e.t = k
k.w = m
c.v = e
m.v = e
d.v = e
assert c.v.t.w.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

e = A("e")
k = B("k")
c = C("c")
m = C("m")
d = C("d")

e.t = k
k.w = m
c.v = e
m.v = e
d.v = e
assert c.v.t.w.v.t.txt == "k"