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

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

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

k = A("k")
l = B("l")
e = C("e")

k.y = l
l.q = k
e.s = k
e.x = k
assert e.s.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

k = A("k")
l = B("l")
e = C("e")

k.y = l
l.q = k
e.s = k
e.x = k
assert e.s.y.q.txt == "k"