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

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

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

m = A("m")
j = B("j")
c = C("c")
i = C("i")

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

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

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

m = A("m")
j = B("j")
c = C("c")
i = C("i")

m.s = i
m.x = j
j.o = c
j.v = c
j.s = m
c.u = m
c.t = m
c.q = i
i.u = m
i.t = m
i.q = c
assert i.q.u.x.v.txt == "c"