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

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

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

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

e.w = l
g.p = e
g.q = f
g.u = l
l.t = g
f.p = e
f.q = g
f.u = l
assert l.t.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

e.w = l
g.p = e
g.q = f
g.u = l
l.t = g
f.p = e
f.q = g
f.u = l
assert l.t.u.t.txt == "g"