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

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

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

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

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

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

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

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

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