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

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

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

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

k = A("k")
f = B("f")
e = C("e")
d = D("d")
i = C("i")
a = D("a")
n = B("n")

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

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

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

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

k = A("k")
f = B("f")
e = C("e")
d = D("d")
i = C("i")
a = D("a")
n = B("n")

k.s = n
f.q = i
f.z = i
f.u = a
f.y = n
e.p = n
d.q = f
d.s = n
d.p = n
i.p = f
a.q = n
a.s = n
a.p = n
n.q = e
n.z = e
n.u = a
n.y = f
assert f.y.z.p.txt == "n"