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

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

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

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

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

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

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

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

i.x = m
i.q = a
i.v = a
m.s = a
m.u = i
m.p = i
a.s = i
assert i.x.u.x.txt == "m"