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

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

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

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

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

m = A("m")
j = B("j")
g = C("g")
k = D("k")
i = E("i")
d = D("d")

m.x = g
m.y = i
j.z = g
j.r = k
j.y = i
g.q = j
g.y = j
g.s = j
g.u = j
g.x = d
k.o = d
k.w = j
i.s = d
d.o = k
d.w = j
assert d.w.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: E = None
        self.txt = txt

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

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

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

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

m = A("m")
j = B("j")
g = C("g")
k = D("k")
i = E("i")
d = D("d")

m.x = g
m.y = i
j.z = g
j.r = k
j.y = i
g.q = j
g.y = j
g.s = j
g.u = j
g.x = d
k.o = d
k.w = j
i.s = d
d.o = k
d.w = j
assert d.w.r.w.txt == "j"