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

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

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

h = A("h")
d = B("d")
l = C("l")
i = B("i")

h.r = l
h.s = l
h.z = d
d.u = h
d.v = l
l.u = d
l.v = h
i.u = h
i.v = l
assert i.v.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.z: B = None
        self.s: C = None
        self.txt = txt

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

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

h = A("h")
d = B("d")
l = C("l")
i = B("i")

h.r = l
h.s = l
h.z = d
d.u = h
d.v = l
l.u = d
l.v = h
i.u = h
i.v = l
assert i.v.v.s.txt == "l"