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

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

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

n = A("n")
f = B("f")
g = C("g")
e = C("e")
b = C("b")
c = A("c")
i = A("i")
m = A("m")
l = A("l")
d = B("d")

n.u = m
n.p = b
n.z = d
f.r = l
g.w = d
g.r = e
e.w = d
e.r = b
b.w = d
b.r = g
c.u = l
c.p = g
c.z = d
i.u = n
i.p = e
i.z = d
m.u = i
m.p = e
m.z = d
l.u = i
l.p = b
l.z = d
d.r = i
assert n.p.w.r.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: C = None
        self.z: B = None
        self.txt = txt

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

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

n = A("n")
f = B("f")
g = C("g")
e = C("e")
b = C("b")
c = A("c")
i = A("i")
m = A("m")
l = A("l")
d = B("d")

n.u = m
n.p = b
n.z = d
f.r = l
g.w = d
g.r = e
e.w = d
e.r = b
b.w = d
b.r = g
c.u = l
c.p = g
c.z = d
i.u = n
i.p = e
i.z = d
m.u = i
m.p = e
m.z = d
l.u = i
l.p = b
l.z = d
d.r = i
assert n.p.w.r.z.r.txt == "i"