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

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

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

g = A("g")
e = B("e")
i = C("i")

g.o = e
g.p = e
g.v = i
e.w = i
e.q = g
i.x = e
assert e.w.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: B = None
        self.v: C = None
        self.txt = txt

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

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

g = A("g")
e = B("e")
i = C("i")

g.o = e
g.p = e
g.v = i
e.w = i
e.q = g
i.x = e
assert e.w.x.q.txt == "g"