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

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

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

class D:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: C = None
        self.p: C = None
        self.t: C = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: C = None
        self.p: C = None
        self.t: C = None
        self.txt = txt

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

a.s = f
f.z = j
f.r = k
f.y = i
i.u = j
d.u = j
d.r = i
d.p = i
d.t = i
n.s = f
j.u = d
j.r = i
j.p = i
j.t = i
k.s = f
assert k.s.z.r.u.txt == "j"