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

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

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

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

i = A("i")
l = B("l")
m = C("m")
c = D("c")
a = A("a")

i.z = l
i.u = l
i.x = m
i.v = c
l.r = m
m.z = c
m.q = c
c.x = m
a.z = l
a.u = l
a.x = m
a.v = c
assert a.x.q.x.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.u: B = None
        self.x: C = None
        self.v: D = None
        self.txt = txt

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

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

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

i = A("i")
l = B("l")
m = C("m")
c = D("c")
a = A("a")

i.z = l
i.u = l
i.x = m
i.v = c
l.r = m
m.z = c
m.q = c
c.x = m
a.z = l
a.u = l
a.x = m
a.v = c
assert a.x.q.x.z.x.txt == "m"