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

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

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

h = A("h")
f = B("f")
m = C("m")
c = A("c")
g = B("g")
l = A("l")

h.v = m
h.s = m
f.z = g
m.y = f
c.v = m
c.s = m
g.z = f
l.v = m
l.s = m
assert c.s.y.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.s: C = None
        self.txt = txt

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

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

h = A("h")
f = B("f")
m = C("m")
c = A("c")
g = B("g")
l = A("l")

h.v = m
h.s = m
f.z = g
m.y = f
c.v = m
c.s = m
g.z = f
l.v = m
l.s = m
assert c.s.y.z.z.txt == "f"