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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

h = A("h")
d = B("d")
g = C("g")
e = D("e")
l = A("l")

h.r = d
h.t = d
h.y = e
d.u = e
g.u = e
e.s = h
l.r = d
l.t = d
l.y = e
assert d.u.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.y: D = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

h = A("h")
d = B("d")
g = C("g")
e = D("e")
l = A("l")

h.r = d
h.t = d
h.y = e
d.u = e
g.u = e
e.s = h
l.r = d
l.t = d
l.y = e
assert d.u.s.r.txt == "d"