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

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

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

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

j = A("j")
a = B("a")
n = C("n")
e = D("e")
k = B("k")
c = C("c")

j.u = a
j.r = a
j.y = n
a.z = k
a.r = k
n.p = c
n.x = k
n.z = k
e.s = k
e.u = c
k.z = a
k.r = a
c.p = n
c.x = a
c.z = a
assert k.r.z.r.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: B = None
        self.y: C = None
        self.txt = txt

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

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

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

j = A("j")
a = B("a")
n = C("n")
e = D("e")
k = B("k")
c = C("c")

j.u = a
j.r = a
j.y = n
a.z = k
a.r = k
n.p = c
n.x = k
n.z = k
e.s = k
e.u = c
k.z = a
k.r = a
c.p = n
c.x = a
c.z = a
assert k.r.z.r.r.z.txt == "a"