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

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

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

j = A("j")
c = B("c")
b = C("b")

j.o = b
j.w = b
c.s = b
c.v = j
b.w = c
assert j.w.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.w: C = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
b = C("b")

j.o = b
j.w = b
c.s = b
c.v = j
b.w = c
assert j.w.w.v.txt == "j"