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

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

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

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

i = A("i")
j = B("j")
a = C("a")
l = D("l")
n = D("n")
g = D("g")
m = C("m")

i.z = j
i.v = a
j.x = n
a.r = j
a.s = i
l.s = j
l.u = n
n.s = j
n.u = l
g.s = j
g.u = l
m.r = j
m.s = i
assert m.r.x.s.x.u.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.v: C = None
        self.txt = txt

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

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

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

i = A("i")
j = B("j")
a = C("a")
l = D("l")
n = D("n")
g = D("g")
m = C("m")

i.z = j
i.v = a
j.x = n
a.r = j
a.s = i
l.s = j
l.u = n
n.s = j
n.u = l
g.s = j
g.u = l
m.r = j
m.s = i
assert m.r.x.s.x.u.s.x.txt == "n"