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

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

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

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

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

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

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

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

m.r = n
m.y = n
c.z = l
c.x = l
n.p = l
n.v = m
n.w = c
l.p = n
l.v = m
l.w = c
d.z = n
d.x = l
k.z = l
k.x = l
a.z = n
a.x = l
assert a.z.p.w.txt == "c"