class A:
    def __init__(self, txt: str):
        self.u: B = 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.t: A = None
        self.v: D = None
        self.txt = txt

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

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

b.u = m
f.z = b
i.t = b
i.v = a
a.w = f
a.s = i
a.r = i
d.u = k
g.t = d
g.v = a
l.z = b
j.t = d
j.v = a
m.z = b
k.z = d
assert i.v.s.t.u.z.u.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = 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.t: A = None
        self.v: D = None
        self.txt = txt

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

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

b.u = m
f.z = b
i.t = b
i.v = a
a.w = f
a.s = i
a.r = i
d.u = k
g.t = d
g.v = a
l.z = b
j.t = d
j.v = a
m.z = b
k.z = d
assert i.v.s.t.u.z.u.z.u.z.txt == "b"