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

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.w: A = None
        self.v: C = None
        self.txt = txt

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

k = A("k")
c = B("c")
f = C("f")
a = D("a")
m = D("m")
l = B("l")
i = B("i")
j = C("j")

k.o = a
c.z = k
f.r = j
f.v = j
f.w = k
a.x = l
a.s = i
m.x = i
m.s = c
l.z = k
i.z = k
j.r = f
j.v = f
j.w = k
assert m.s.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.w: A = None
        self.v: C = None
        self.txt = txt

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

k = A("k")
c = B("c")
f = C("f")
a = D("a")
m = D("m")
l = B("l")
i = B("i")
j = C("j")

k.o = a
c.z = k
f.r = j
f.v = j
f.w = k
a.x = l
a.s = i
m.x = i
m.s = c
l.z = k
i.z = k
j.r = f
j.v = f
j.w = k
assert m.s.z.o.txt == "a"