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

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: E = None
        self.p: A = None
        self.z: D = None
        self.u: B = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: E = None
        self.p: A = None
        self.z: D = None
        self.u: B = None
        self.txt = txt

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

n.r = m
m.x = h
m.z = h
m.r = i
m.w = b
h.v = n
h.s = n
i.v = h
c.w = i
c.z = i
c.q = f
c.p = n
c.u = m
b.w = i
b.z = i
b.q = c
b.p = n
b.u = m
f.w = i
f.z = i
f.q = b
f.p = n
f.u = m
d.v = n
d.s = n
l.w = i
l.z = i
l.q = b
l.p = n
l.u = m
assert d.s.r.z.s.r.w.q.q.txt == "f"