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

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

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

e = A("e")
g = B("g")
a = C("a")
b = A("b")

e.y = a
e.o = a
e.r = a
g.s = e
a.w = g
a.q = g
b.y = a
b.o = a
b.r = a
assert g.s.y.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.o: C = None
        self.r: C = None
        self.txt = txt

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

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

e = A("e")
g = B("g")
a = C("a")
b = A("b")

e.y = a
e.o = a
e.r = a
g.s = e
a.w = g
a.q = g
b.y = a
b.o = a
b.r = a
assert g.s.y.w.s.txt == "e"