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

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

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

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

d = A("d")
i = B("i")
a = C("a")
e = D("e")
l = B("l")
j = D("j")

d.r = i
d.q = i
d.w = j
i.w = e
i.t = e
i.u = j
a.u = d
e.q = d
e.p = d
l.w = j
l.t = j
l.u = j
j.q = d
j.p = d
assert a.u.w.q.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: B = None
        self.w: D = None
        self.txt = txt

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

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

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

d = A("d")
i = B("i")
a = C("a")
e = D("e")
l = B("l")
j = D("j")

d.r = i
d.q = i
d.w = j
i.w = e
i.t = e
i.u = j
a.u = d
e.q = d
e.p = d
l.w = j
l.t = j
l.u = j
j.q = d
j.p = d
assert a.u.w.q.q.u.q.txt == "d"