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

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

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

a = A("a")
e = B("e")
c = C("c")

a.s = e
e.u = a
e.v = a
e.q = c
c.o = e
c.p = e
assert e.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

a = A("a")
e = B("e")
c = C("c")

a.s = e
e.u = a
e.v = a
e.q = c
c.o = e
c.p = e
assert e.v.s.v.txt == "a"