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

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

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

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

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

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

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

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

m.y = i
m.p = k
m.w = d
n.x = c
n.z = i
i.u = c
k.y = i
k.w = i
k.p = m
d.u = c
a.u = n
j.y = d
j.p = m
j.w = a
c.x = n
c.z = a
assert n.z.u.x.z.u.txt == "c"