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

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

class C:
    def __init__(self, txt: str):
        self.x: E = None
        self.y: E = None
        self.t: B = None
        self.v: B = None
        self.s: E = None
        self.txt = txt

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

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

m = A("m")
i = B("i")
d = C("d")
c = D("c")
g = E("g")
h = B("h")
l = E("l")

m.y = l
i.z = c
i.w = h
d.x = g
d.s = g
d.y = l
d.t = h
d.v = i
c.p = d
c.x = i
c.y = m
c.u = m
c.t = m
g.y = c
h.z = c
h.w = i
l.y = c
assert d.t.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: E = None
        self.y: E = None
        self.t: B = None
        self.v: B = None
        self.s: E = None
        self.txt = txt

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

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

m = A("m")
i = B("i")
d = C("d")
c = D("c")
g = E("g")
h = B("h")
l = E("l")

m.y = l
i.z = c
i.w = h
d.x = g
d.s = g
d.y = l
d.t = h
d.v = i
c.p = d
c.x = i
c.y = m
c.u = m
c.t = m
g.y = c
h.z = c
h.w = i
l.y = c
assert d.t.w.z.txt == "c"