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

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

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

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

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

b = A("b")
j = B("j")
h = C("h")
m = D("m")
d = E("d")
n = D("n")
i = C("i")
f = C("f")

b.r = j
j.p = d
j.y = d
h.w = j
h.x = m
h.u = f
h.y = f
m.z = n
d.x = h
n.z = m
i.w = j
i.x = n
i.u = f
i.y = h
f.w = j
f.x = n
f.u = i
f.y = h
assert m.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

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

b = A("b")
j = B("j")
h = C("h")
m = D("m")
d = E("d")
n = D("n")
i = C("i")
f = C("f")

b.r = j
j.p = d
j.y = d
h.w = j
h.x = m
h.u = f
h.y = f
m.z = n
d.x = h
n.z = m
i.w = j
i.x = n
i.u = f
i.y = h
f.w = j
f.x = n
f.u = i
f.y = h
assert m.z.z.z.txt == "n"