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

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

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

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

e.p = k
e.r = n
n.z = e
n.q = e
b.y = n
k.y = n
assert b.y.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: B = None
        self.txt = txt

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

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

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

e.p = k
e.r = n
n.z = e
n.q = e
b.y = n
k.y = n
assert b.y.z.r.txt == "n"