class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: A = None
        self.txt = txt

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

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

n = A("n")
d = B("d")
c = C("c")
m = C("m")
e = B("e")
k = B("k")
a = A("a")

n.q = c
n.u = a
d.x = e
d.r = c
d.v = c
c.u = m
c.p = m
c.z = e
m.u = c
m.p = c
m.z = d
e.x = k
e.r = c
e.v = m
k.x = d
k.r = m
k.v = m
a.q = m
a.u = n
assert m.p.p.z.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: A = None
        self.txt = txt

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

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

n = A("n")
d = B("d")
c = C("c")
m = C("m")
e = B("e")
k = B("k")
a = A("a")

n.q = c
n.u = a
d.x = e
d.r = c
d.v = c
c.u = m
c.p = m
c.z = e
m.u = c
m.p = c
m.z = d
e.x = k
e.r = c
e.v = m
k.x = d
k.r = m
k.v = m
a.q = m
a.u = n
assert m.p.p.z.v.z.txt == "e"