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

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

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

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

l.u = g
g.s = a
a.w = g
a.v = e
e.u = g
assert l.u.s.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

l.u = g
g.s = a
a.w = g
a.v = e
e.u = g
assert l.u.s.v.u.txt == "g"