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

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

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

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

a.x = e
a.q = e
a.s = g
g.y = h
g.w = h
g.u = e
e.y = g
e.p = a
h.y = g
h.p = a
assert e.y.y.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: C = None
        self.s: B = None
        self.txt = txt

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

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

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

a.x = e
a.q = e
a.s = g
g.y = h
g.w = h
g.u = e
e.y = g
e.p = a
h.y = g
h.p = a
assert e.y.y.y.u.txt == "e"