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

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

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

i = A("i")
m = B("m")
k = C("k")

i.x = m
i.q = m
i.v = k
m.s = i
k.r = i
assert m.s.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.q: B = None
        self.v: C = None
        self.txt = txt

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

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

i = A("i")
m = B("m")
k = C("k")

i.x = m
i.q = m
i.v = k
m.s = i
k.r = i
assert m.s.v.r.txt == "i"