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

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

n = A("n")
a = B("a")
l = A("l")
m = A("m")
b = A("b")
c = B("c")
k = A("k")
e = A("e")

n.p = c
n.q = a
a.t = k
l.p = a
l.q = c
m.p = c
m.q = c
b.p = a
b.q = a
c.t = k
k.p = c
k.q = a
e.p = a
e.q = a
assert a.t.p.t.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: B = None
        self.txt = txt

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

n = A("n")
a = B("a")
l = A("l")
m = A("m")
b = A("b")
c = B("c")
k = A("k")
e = A("e")

n.p = c
n.q = a
a.t = k
l.p = a
l.q = c
m.p = c
m.q = c
b.p = a
b.q = a
c.t = k
k.p = c
k.q = a
e.p = a
e.q = a
assert a.t.p.t.q.t.txt == "k"