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

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

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

i = A("i")
l = B("l")
g = C("g")
m = B("m")

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

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

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

i = A("i")
l = B("l")
g = C("g")
m = B("m")

i.u = m
i.v = m
i.w = g
l.q = m
l.p = m
l.w = i
g.q = m
g.t = i
m.q = l
m.p = l
m.w = i
assert l.q.w.w.t.txt == "i"