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

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

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

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

i.u = d
i.q = j
j.y = d
d.q = i
d.t = i
d.x = j
assert j.y.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: B = None
        self.txt = txt

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

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

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

i.u = d
i.q = j
j.y = d
d.q = i
d.t = i
d.x = j
assert j.y.t.q.txt == "j"