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

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

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

e = A("e")
f = B("f")
g = C("g")
c = B("c")

e.q = c
e.r = c
f.s = g
f.w = c
f.u = c
g.y = e
g.s = e
c.s = g
c.w = f
c.u = f
assert c.u.w.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: B = None
        self.txt = txt

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

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

e = A("e")
f = B("f")
g = C("g")
c = B("c")

e.q = c
e.r = c
f.s = g
f.w = c
f.u = c
g.y = e
g.s = e
c.s = g
c.w = f
c.u = f
assert c.u.w.s.y.txt == "e"