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

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

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

c = A("c")
j = B("j")
k = C("k")
l = C("l")

c.x = j
c.s = j
j.v = k
j.w = k
j.o = k
k.w = c
l.w = c
assert k.w.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: B = None
        self.txt = txt

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

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

c = A("c")
j = B("j")
k = C("k")
l = C("l")

c.x = j
c.s = j
j.v = k
j.w = k
j.o = k
k.w = c
l.w = c
assert k.w.s.v.txt == "k"