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

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

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

k = A("k")
c = B("c")
f = C("f")
h = B("h")

k.z = f
c.s = h
f.v = c
f.u = k
f.s = k
h.s = c
assert c.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

k = A("k")
c = B("c")
f = C("f")
h = B("h")

k.z = f
c.s = h
f.v = c
f.u = k
f.s = k
h.s = c
assert c.s.s.s.s.txt == "c"