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

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

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

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

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

h = A("h")
f = B("f")
c = C("c")
n = D("n")
g = E("g")
e = B("e")

h.s = g
h.p = g
h.q = c
f.w = e
f.z = e
c.p = f
c.q = g
n.o = g
n.t = g
g.t = c
e.w = f
e.z = f
assert c.p.z.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: E = None
        self.p: E = None
        self.q: C = None
        self.txt = txt

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

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

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

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

h = A("h")
f = B("f")
c = C("c")
n = D("n")
g = E("g")
e = B("e")

h.s = g
h.p = g
h.q = c
f.w = e
f.z = e
c.p = f
c.q = g
n.o = g
n.t = g
g.t = c
e.w = f
e.z = f
assert c.p.z.w.z.txt == "e"