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

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

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

i = A("i")
d = B("d")
b = C("b")
e = C("e")

i.r = e
d.t = i
d.q = i
b.v = e
b.u = d
e.v = b
e.u = d
assert i.r.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

i = A("i")
d = B("d")
b = C("b")
e = C("e")

i.r = e
d.t = i
d.q = i
b.v = e
b.u = d
e.v = b
e.u = d
assert i.r.u.t.txt == "i"