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

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

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

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

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

h.u = d
f.z = a
f.v = a
a.s = d
d.o = h
d.w = f
c.o = h
c.w = f
k.z = a
k.v = a
l.z = a
l.v = a
assert a.s.w.z.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

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

h.u = d
f.z = a
f.v = a
a.s = d
d.o = h
d.w = f
c.o = h
c.w = f
k.z = a
k.v = a
l.z = a
l.v = a
assert a.s.w.z.s.o.txt == "h"