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

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

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

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

h = A("h")
l = B("l")
a = C("a")
d = D("d")
b = B("b")

h.t = a
h.s = a
h.y = b
l.w = b
l.u = b
l.q = a
a.r = d
a.u = d
d.y = l
b.w = l
b.u = l
b.q = a
assert b.u.w.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.s: C = None
        self.y: B = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
a = C("a")
d = D("d")
b = B("b")

h.t = a
h.s = a
h.y = b
l.w = b
l.u = b
l.q = a
a.r = d
a.u = d
d.y = l
b.w = l
b.u = l
b.q = a
assert b.u.w.q.r.txt == "d"