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.t: B = None
        self.txt = txt

a = A("a")
n = B("n")
j = B("j")
e = A("e")
k = B("k")
c = A("c")
g = A("g")

a.p = n
a.z = n
n.t = j
j.t = k
e.p = j
e.z = k
k.t = n
c.p = j
c.z = j
g.p = n
g.z = n
assert j.t.t.t.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.t: B = None
        self.txt = txt

a = A("a")
n = B("n")
j = B("j")
e = A("e")
k = B("k")
c = A("c")
g = A("g")

a.p = n
a.z = n
n.t = j
j.t = k
e.p = j
e.z = k
k.t = n
c.p = j
c.z = j
g.p = n
g.z = n
assert j.t.t.t.txt == "j"