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

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

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

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

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

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

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

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

a.r = h
a.w = e
h.x = d
h.w = d
d.r = h
d.t = e
e.r = h
e.t = d
assert h.x.t.t.txt == "d"