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

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

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

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

a = A("a")
h = B("h")
f = C("f")
k = D("k")
l = C("l")
n = D("n")

a.s = l
a.o = h
a.z = h
a.u = f
h.q = a
f.w = h
f.p = a
f.o = k
k.w = a
k.y = f
l.w = h
l.p = a
l.o = k
n.w = a
n.y = f
assert f.o.w.z.q.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.o: B = None
        self.z: B = None
        self.u: C = None
        self.txt = txt

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

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

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

a = A("a")
h = B("h")
f = C("f")
k = D("k")
l = C("l")
n = D("n")

a.s = l
a.o = h
a.z = h
a.u = f
h.q = a
f.w = h
f.p = a
f.o = k
k.w = a
k.y = f
l.w = h
l.p = a
l.o = k
n.w = a
n.y = f
assert f.o.w.z.q.s.o.txt == "k"