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

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

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

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

a = A("a")
c = B("c")
n = C("n")
d = D("d")
m = C("m")
i = D("i")
f = C("f")
j = B("j")

a.z = m
a.y = j
c.u = m
n.w = m
n.q = a
d.y = c
d.v = c
d.r = a
m.w = f
m.q = a
i.y = c
i.v = c
i.r = a
f.w = n
f.q = a
j.u = f
assert a.y.u.w.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: B = None
        self.txt = txt

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

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

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

a = A("a")
c = B("c")
n = C("n")
d = D("d")
m = C("m")
i = D("i")
f = C("f")
j = B("j")

a.z = m
a.y = j
c.u = m
n.w = m
n.q = a
d.y = c
d.v = c
d.r = a
m.w = f
m.q = a
i.y = c
i.v = c
i.r = a
f.w = n
f.q = a
j.u = f
assert a.y.u.w.q.y.txt == "j"