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

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

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

a = A("a")
h = B("h")
d = C("d")
m = A("m")
f = B("f")
l = C("l")
j = C("j")
i = A("i")
g = A("g")
c = C("c")

a.x = l
a.v = h
a.r = f
h.p = f
h.z = l
d.u = h
d.p = h
d.v = c
m.x = j
m.v = f
m.r = f
f.p = h
f.z = j
l.u = f
l.p = h
l.v = d
j.u = f
j.p = h
j.v = d
i.x = c
i.v = f
i.r = h
g.x = d
g.v = f
g.r = f
c.u = h
c.p = f
c.v = l
assert m.r.p.z.u.z.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: B = None
        self.r: B = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
d = C("d")
m = A("m")
f = B("f")
l = C("l")
j = C("j")
i = A("i")
g = A("g")
c = C("c")

a.x = l
a.v = h
a.r = f
h.p = f
h.z = l
d.u = h
d.p = h
d.v = c
m.x = j
m.v = f
m.r = f
f.p = h
f.z = j
l.u = f
l.p = h
l.v = d
j.u = f
j.p = h
j.v = d
i.x = c
i.v = f
i.r = h
g.x = d
g.v = f
g.r = f
c.u = h
c.p = f
c.v = l
assert m.r.p.z.u.z.p.p.txt == "f"