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

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

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

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

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

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

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

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

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

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

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