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

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

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

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

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

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

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

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

l.u = j
l.w = g
e.p = l
e.w = l
g.w = l
g.q = l
g.y = e
j.p = l
j.w = l
assert g.q.u.w.txt == "l"