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

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

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

n = A("n")
j = B("j")
d = C("d")

n.w = j
n.q = d
j.v = d
j.r = d
j.s = n
d.v = j
d.r = j
d.s = n
assert j.s.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: C = None
        self.txt = txt

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

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

n = A("n")
j = B("j")
d = C("d")

n.w = j
n.q = d
j.v = d
j.r = d
j.s = n
d.v = j
d.r = j
d.s = n
assert j.s.w.s.txt == "n"