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

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

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

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

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

m = A("m")
a = B("a")
i = C("i")
f = D("f")
l = E("l")
g = A("g")
d = C("d")
h = D("h")

m.r = f
a.z = d
i.z = f
i.v = d
i.u = l
f.w = g
l.q = a
l.v = i
l.y = m
g.r = f
d.z = f
d.v = i
d.u = l
h.w = g
assert a.z.u.v.u.q.z.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

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

m = A("m")
a = B("a")
i = C("i")
f = D("f")
l = E("l")
g = A("g")
d = C("d")
h = D("h")

m.r = f
a.z = d
i.z = f
i.v = d
i.u = l
f.w = g
l.q = a
l.v = i
l.y = m
g.r = f
d.z = f
d.v = i
d.u = l
h.w = g
assert a.z.u.v.u.q.z.v.v.txt == "d"