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

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

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

j = A("j")
g = B("g")
h = C("h")

j.s = g
j.r = h
g.v = j
g.z = j
h.z = g
assert j.r.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: C = None
        self.txt = txt

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

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

j = A("j")
g = B("g")
h = C("h")

j.s = g
j.r = h
g.v = j
g.z = j
h.z = g
assert j.r.z.z.txt == "j"