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

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

c = A("c")
i = B("i")
h = A("h")
l = A("l")
b = A("b")
k = B("k")

c.q = k
i.p = k
i.z = k
h.q = i
l.q = i
b.q = i
k.p = i
k.z = i
assert l.q.z.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

c = A("c")
i = B("i")
h = A("h")
l = A("l")
b = A("b")
k = B("k")

c.q = k
i.p = k
i.z = k
h.q = i
l.q = i
b.q = i
k.p = i
k.z = i
assert l.q.z.p.p.txt == "k"