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

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.q: B = None
        self.z: D = None
        self.txt = txt

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

l = A("l")
g = B("g")
e = C("e")
j = D("j")
n = B("n")
c = D("c")

l.w = n
l.q = e
l.u = e
l.y = j
g.r = j
g.q = j
e.s = c
e.q = g
e.z = j
j.p = e
j.u = e
j.q = c
n.r = j
n.q = c
c.p = e
c.u = e
c.q = j
assert c.u.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: C = None
        self.u: C = None
        self.y: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.q: B = None
        self.z: D = None
        self.txt = txt

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

l = A("l")
g = B("g")
e = C("e")
j = D("j")
n = B("n")
c = D("c")

l.w = n
l.q = e
l.u = e
l.y = j
g.r = j
g.q = j
e.s = c
e.q = g
e.z = j
j.p = e
j.u = e
j.q = c
n.r = j
n.q = c
c.p = e
c.u = e
c.q = j
assert c.u.q.r.txt == "j"