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

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

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

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

b = A("b")
a = B("a")
f = C("f")
k = D("k")
m = C("m")
j = B("j")
d = B("d")

b.z = j
a.y = b
a.o = b
a.u = k
f.s = d
f.o = m
k.w = j
k.s = b
k.q = b
m.s = j
m.o = f
j.y = b
j.o = b
j.u = k
d.y = b
d.o = b
d.u = k
assert j.y.z.u.w.y.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

b = A("b")
a = B("a")
f = C("f")
k = D("k")
m = C("m")
j = B("j")
d = B("d")

b.z = j
a.y = b
a.o = b
a.u = k
f.s = d
f.o = m
k.w = j
k.s = b
k.q = b
m.s = j
m.o = f
j.y = b
j.o = b
j.u = k
d.y = b
d.o = b
d.u = k
assert j.y.z.u.w.y.z.u.txt == "k"