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

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

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

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

m = A("m")
j = B("j")
k = C("k")
i = D("i")
a = B("a")
e = A("e")

m.z = a
m.y = i
m.s = j
j.u = k
k.p = e
k.o = j
i.s = k
i.u = a
a.u = k
e.z = j
e.y = i
e.s = a
assert k.o.u.o.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.y: D = None
        self.s: B = None
        self.txt = txt

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

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

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

m = A("m")
j = B("j")
k = C("k")
i = D("i")
a = B("a")
e = A("e")

m.z = a
m.y = i
m.s = j
j.u = k
k.p = e
k.o = j
i.s = k
i.u = a
a.u = k
e.z = j
e.y = i
e.s = a
assert k.o.u.o.u.o.txt == "j"