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

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

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

g = A("g")
l = B("l")
a = C("a")

g.o = l
g.w = a
l.y = g
l.s = g
l.v = g
a.x = l
a.q = l
a.y = g
assert g.w.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: C = None
        self.txt = txt

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

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

g = A("g")
l = B("l")
a = C("a")

g.o = l
g.w = a
l.y = g
l.s = g
l.v = g
a.x = l
a.q = l
a.y = g
assert g.w.q.y.txt == "g"