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

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

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

j = A("j")
d = B("d")
m = C("m")

j.u = m
j.w = m
d.r = m
m.q = j
m.u = j
m.t = j
assert m.q.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.w: C = None
        self.txt = txt

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

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

j = A("j")
d = B("d")
m = C("m")

j.u = m
j.w = m
d.r = m
m.q = j
m.u = j
m.t = j
assert m.q.u.u.txt == "j"