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

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

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

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

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

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

n.y = a
n.s = d
h.s = n
m.x = c
f.w = n
f.p = a
f.x = h
f.s = h
f.q = i
a.z = c
a.x = i
i.z = c
i.x = a
d.s = n
j.s = n
k.w = n
k.p = i
k.q = i
k.x = d
k.s = h
c.x = m
assert a.z.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.s: B = None
        self.txt = txt

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

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

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

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

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

n.y = a
n.s = d
h.s = n
m.x = c
f.w = n
f.p = a
f.x = h
f.s = h
f.q = i
a.z = c
a.x = i
i.z = c
i.x = a
d.s = n
j.s = n
k.w = n
k.p = i
k.q = i
k.x = d
k.s = h
c.x = m
assert a.z.x.x.x.x.x.x.txt == "c"