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

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

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

d = A("d")
c = B("c")
h = C("h")
a = B("a")
e = B("e")
l = A("l")

d.r = c
c.v = l
h.t = c
h.w = d
h.z = e
a.v = d
e.v = l
l.r = a
assert d.r.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

d = A("d")
c = B("c")
h = C("h")
a = B("a")
e = B("e")
l = A("l")

d.r = c
c.v = l
h.t = c
h.w = d
h.z = e
a.v = d
e.v = l
l.r = a
assert d.r.v.r.txt == "a"