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

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

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

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

l.x = i
j.q = l
j.u = l
i.o = l
i.p = l
i.r = l
assert l.x.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

l.x = i
j.q = l
j.u = l
i.o = l
i.p = l
i.r = l
assert l.x.o.x.txt == "i"