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

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

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

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

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

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

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

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

d.x = j
d.r = b
n.y = j
n.w = e
n.z = m
e.r = n
e.v = j
e.x = k
a.r = k
a.x = k
a.v = d
c.x = d
c.r = b
b.r = n
b.v = j
b.x = m
m.y = d
m.w = b
m.z = n
j.x = d
j.r = a
k.y = d
k.w = e
k.z = m
assert m.w.x.z.z.w.r.txt == "n"