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

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

a = A("a")
j = B("j")
h = A("h")
l = A("l")
n = B("n")
k = A("k")
e = A("e")

a.p = j
a.z = k
j.t = n
h.p = j
h.z = e
l.p = j
l.z = a
n.t = j
k.p = n
k.z = h
e.p = j
e.z = h
assert e.p.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: A = None
        self.txt = txt

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

a = A("a")
j = B("j")
h = A("h")
l = A("l")
n = B("n")
k = A("k")
e = A("e")

a.p = j
a.z = k
j.t = n
h.p = j
h.z = e
l.p = j
l.z = a
n.t = j
k.p = n
k.z = h
e.p = j
e.z = h
assert e.p.t.t.t.t.t.txt == "n"