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

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

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

f = A("f")
g = B("g")
d = C("d")
b = B("b")
h = B("h")
m = A("m")
i = B("i")
k = C("k")
c = A("c")
n = B("n")

f.z = i
f.y = n
f.p = k
g.r = i
g.v = b
d.s = f
b.r = h
b.v = g
h.r = b
h.v = i
m.z = n
m.y = n
m.p = k
i.r = h
i.v = g
k.s = c
c.z = g
c.y = b
c.p = k
n.r = i
n.v = g
assert k.s.p.s.z.r.v.r.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.y: B = None
        self.p: C = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
d = C("d")
b = B("b")
h = B("h")
m = A("m")
i = B("i")
k = C("k")
c = A("c")
n = B("n")

f.z = i
f.y = n
f.p = k
g.r = i
g.v = b
d.s = f
b.r = h
b.v = g
h.r = b
h.v = i
m.z = n
m.y = n
m.p = k
i.r = h
i.v = g
k.s = c
c.z = g
c.y = b
c.p = k
n.r = i
n.v = g
assert k.s.p.s.z.r.v.r.v.v.txt == "b"