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

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.z: B = None
        self.p: B = None
        self.y: A = None
        self.txt = txt

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

e = A("e")
i = B("i")
m = C("m")
f = D("f")
n = E("n")
h = B("h")

e.s = n
i.y = f
m.q = n
m.r = n
f.r = n
f.z = i
f.p = h
f.y = e
n.u = i
n.r = m
n.w = e
h.y = f
assert i.y.z.y.z.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.z: B = None
        self.p: B = None
        self.y: A = None
        self.txt = txt

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

e = A("e")
i = B("i")
m = C("m")
f = D("f")
n = E("n")
h = B("h")

e.s = n
i.y = f
m.q = n
m.r = n
f.r = n
f.z = i
f.p = h
f.y = e
n.u = i
n.r = m
n.w = e
h.y = f
assert i.y.z.y.z.y.r.txt == "n"