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

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.u: E = None
        self.txt = txt

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

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

f.s = a
i.y = f
i.w = a
i.t = a
i.s = a
i.z = m
a.w = i
a.q = i
a.x = m
a.s = n
m.v = n
m.u = d
d.w = m
d.p = i
d.q = i
n.s = a
assert m.u.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.u: E = None
        self.txt = txt

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

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

f.s = a
i.y = f
i.w = a
i.t = a
i.s = a
i.z = m
a.w = i
a.q = i
a.x = m
a.s = n
m.v = n
m.u = d
d.w = m
d.p = i
d.q = i
n.s = a
assert m.u.w.u.w.txt == "m"