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

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

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

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

l.x = n
j.x = n
j.z = l
n.o = j
n.q = j
assert j.x.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

l.x = n
j.x = n
j.z = l
n.o = j
n.q = j
assert j.x.q.x.txt == "n"