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

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

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

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

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

j.z = g
g.v = f
g.u = b
g.w = b
d.t = l
d.s = g
f.z = g
f.s = d
f.q = d
l.z = b
m.t = l
m.s = g
b.v = f
b.u = g
b.w = g
assert m.s.u.v.z.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

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

j.z = g
g.v = f
g.u = b
g.w = b
d.t = l
d.s = g
f.z = g
f.s = d
f.q = d
l.z = b
m.t = l
m.s = g
b.v = f
b.u = g
b.w = g
assert m.s.u.v.z.v.q.txt == "d"