class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: C = 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.u: A = None
        self.z: B = None
        self.txt = txt

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

b.q = e
b.p = e
n.q = b
e.u = b
e.z = n
assert n.q.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: C = 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.u: A = None
        self.z: B = None
        self.txt = txt

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

b.q = e
b.p = e
n.q = b
e.u = b
e.z = n
assert n.q.p.z.txt == "n"