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

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

j = A("j")
k = B("k")
e = B("e")
n = B("n")
d = B("d")
i = B("i")

j.p = n
j.z = d
k.p = j
k.q = j
e.p = j
e.q = j
n.p = j
n.q = j
d.p = j
d.q = j
i.p = j
i.q = j
assert n.q.p.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: B = None
        self.txt = txt

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

j = A("j")
k = B("k")
e = B("e")
n = B("n")
d = B("d")
i = B("i")

j.p = n
j.z = d
k.p = j
k.q = j
e.p = j
e.q = j
n.p = j
n.q = j
d.p = j
d.q = j
i.p = j
i.q = j
assert n.q.p.q.p.txt == "n"