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

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: D = None
        self.q: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

f.s = n
i.z = f
i.u = m
i.q = k
k.u = n
k.s = f
k.z = i
m.q = f
d.q = k
d.y = k
n.s = f
j.q = k
j.y = k
assert j.q.z.q.z.u.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: D = None
        self.q: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

f.s = n
i.z = f
i.u = m
i.q = k
k.u = n
k.s = f
k.z = i
m.q = f
d.q = k
d.y = k
n.s = f
j.q = k
j.y = k
assert j.q.z.q.z.u.q.s.txt == "n"