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

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

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

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

i.u = j
i.s = j
i.w = g
g.w = j
g.p = i
j.v = i
j.s = i
j.p = g
assert g.p.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.s: C = None
        self.w: B = None
        self.txt = txt

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

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

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

i.u = j
i.s = j
i.w = g
g.w = j
g.p = i
j.v = i
j.s = i
j.p = g
assert g.p.w.w.txt == "j"