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

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

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

e = A("e")
b = B("b")
a = C("a")

e.x = a
b.q = a
b.t = a
b.x = a
a.x = e
a.p = b
assert a.p.t.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: C = None
        self.t: C = None
        self.x: C = None
        self.txt = txt

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

e = A("e")
b = B("b")
a = C("a")

e.x = a
b.q = a
b.t = a
b.x = a
a.x = e
a.p = b
assert a.p.t.x.txt == "e"